Update of /project/corman-sdl/cvsroot/corman-sdl/ffi In directory common-lisp.net:/tmp/cvs-serv6276/ffi
Modified Files: engine.lisp Log Message:
Date: Thu Jul 8 01:48:34 2004 Author: lcrook
Index: corman-sdl/ffi/engine.lisp diff -u corman-sdl/ffi/engine.lisp:1.1 corman-sdl/ffi/engine.lisp:1.2 --- corman-sdl/ffi/engine.lisp:1.1 Tue Apr 13 10:09:40 2004 +++ corman-sdl/ffi/engine.lisp Thu Jul 8 01:48:34 2004 @@ -73,15 +73,21 @@ (return obj) (setf obj (dl-next obj))))))
-(defstruct (zlevel) - zorder - start - end) - +;;;;; End: Link list functions +;;;;;
+(defun create-display-list () + (let ((display-list nil)) + (defun init-display-list () + (setf display-list nil)) + (defun display-list () + display-list)))
-(defvar objects nil) +(defstruct (level) + zorder + start + end)
(defclass sprite () ( @@ -90,32 +96,46 @@ (y :accessor sprite-y :initform 0 :initarg :y) (zorder :accessor sprite-zorder :initform 0 :initarg :zorder)))
+(defun new-level (zorder) + (make-level :zorder zorder))
-(defun addto-level (zlevel obj) +(defun addto-level (level object) (cond - ((null (zlevel-end zlevel)) - (setf (zlevel-end zlevel) (dl-list obj)) - (setf (zlevel-start zlevel) (zlevel-end zlevel))) + ((null (level-end level)) + (setf (level-end level) (dl-list object)) + (setf (level-start level) (level-end level))) (t - (setf (zlevel-end zlevel) (dl-append obj (zlevel-end zlevel)))))) + (setf (level-end level) (dl-append object (level-end level)))))) + +;Removes a node from the level. +(defun remove-node-from-level (level object) + (when (null (dl-next object)) + (setf (level-end level) (dl-prev object))) + (when (null (dl-prev object)) + (setf (level-start level) (dl-next object))) + (dl-remove object)) + +;Finds the node containing object, then calls remove-node-from-level +(defun remove-from-level (level object) + (let ((obj (dl-find (level-start level) + #'(lambda (node) + (if (equal (dl-data node) object) + node + nil))))) + (when obj + (remove-node-from-level level obj))))
-(defun add-level (objects level) +(defun add-level (level objects) (cond - ((null (zlevel-end zlevel)) - (setf (zlevel-end zlevel) (dl-list obj)) - (setf (zlevel-start zlevel) (zlevel-end zlevel))) + ((null objects) + (setf objects (dl-list level))) + ((null (level-end level)) + (setf (level-end level) (dl-list objects)) + (setf (level-start level) (level-end level))) (t - (setf (zlevel-end zlevel) (dl-append obj (zlevel-end zlevel)))))) + (setf (level-end level) (dl-append objects (level-end level))))))
-(defun remove-from-level (zlevel obj) - (when (null (dl-next obj)) - (setf (zlevel-end zlevel) (dl-prev obj))) - (when (null (dl-prev obj)) - (setf (zlevel-start zlevel) (dl-next obj))) - (dl-remove obj))
-(defun new-zlevel (zorder) - (make-zlevel :zorder zorder))
(defun new-find-zlevel (zorder) #'(lambda (dl)
corman-sdl-cvs@common-lisp.net