[corman-sdl-cvs] CVS update: corman-sdl/engine/engine.lisp corman-sdl/engine/use-engine.lisp
Luke J Crook
lcrook at common-lisp.net
Fri Jul 9 15:29:40 UTC 2004
Update of /project/corman-sdl/cvsroot/corman-sdl/engine
In directory common-lisp.net:/tmp/cvs-serv29312/engine
Modified Files:
engine.lisp use-engine.lisp
Log Message:
Date: Fri Jul 9 08:29:40 2004
Author: lcrook
Index: corman-sdl/engine/engine.lisp
diff -u corman-sdl/engine/engine.lisp:1.9 corman-sdl/engine/engine.lisp:1.10
--- corman-sdl/engine/engine.lisp:1.9 Thu Jul 8 02:00:12 2004
+++ corman-sdl/engine/engine.lisp Fri Jul 9 08:29:40 2004
@@ -84,10 +84,8 @@
(return obj)
(setf obj (dl-next obj))))))
-
-
-
-
+;;;;; End: Link list functions
+;;;;;
(defstruct (bitplane)
@@ -105,6 +103,7 @@
(defun set-bitplane (bitplane)
(setf bitplanes bitplane)))
+
(defclass sprite ()
(
(id :accessor sprite-id :initform nil :initarg :id)
@@ -147,17 +146,41 @@
(bitplane-zorder obj))
((dl-p obj)
(bitplane-zorder (dl-data obj)))))
-
+
+;Iterates through the list of bitplanes.
+; Returns the bitplane, if bitplane == zorder.
+; Returns the previous bitplane if bitplane < zorder
+; Returns
(defun find-bitplane (zorder bitplanes)
(let ((bp bitplanes) (quit nil))
(loop
- (when (equal quit t) (return (values bp 'n)))
- (if (> zorder (get-zorder bp)) ; if test > current
- (if (null (dl-next bp))
- (setf quit t) ; end of list when next is null
- (setf bp (dl-next bp))) ; next node
+ (when (equal quit t) (return (values bitplanes 'p)))
+ (cond
+ ((> zorder (get-zorder bp)) ; if test > current
+ (values (bp 'n))) ; end of list when next is null
+ ((equal zorder (get-zorder bp))
+ (return (values bp 'c))) ; test == curent, return
+ ((null (dl-next bp))
+ (setf quit t))))))
+
+(defun add-bitplane (bitplane bitplanes)
+ (let ((bp bitplanes) (quit nil) (zorder (get-zorder bitplane)))
+ (loop
+ (when (equal quit t) (return (values bitplanes 'p)))
+ (cond
+ ((> zorder (get-zorder bitplanes)) ; if test > current
+ (dl-insert bitplane bitplanes))
+ (values (bp 'n))) ; end of list when next is null
+ ((equal zorder (get-zorder bp))
+ (return (values bp 'c))) ; test == curent, return
+ ((null (dl-next bp))
+ (setf quit t))))))
+
+
+
+
(if (equal zorder (get-zorder bp))
- (return (values bp 'c)) ; test == curent, return
+ (return (values bp 'c))
(return (values bp 'p))))))) ; test < current, return
(defun return-bitplane (zorder bitplanes)
Index: corman-sdl/engine/use-engine.lisp
diff -u corman-sdl/engine/use-engine.lisp:1.1 corman-sdl/engine/use-engine.lisp:1.2
--- corman-sdl/engine/use-engine.lisp:1.1 Thu Jul 8 02:00:12 2004
+++ corman-sdl/engine/use-engine.lisp Fri Jul 9 08:29:40 2004
@@ -1,23 +1,12 @@
; Create a new level
-(setf objects (add-level objects (new-zlevel 5)))
-(dl-list (new-zlevel 5))
-objects
+(set-bitplane (new-bitplane 5))
-(find-zlevel objects 5)
+(addto-bitplane (bitplanes) 'obj-1)
+(addto-bitplane (bitplanes) 'obj-2)
+(addto-bitplane (bitplanes) 'obj-5)
+(addto-bitplane (bitplanes) 'obj-10)
-(setf level-1 (new-level 1))
+(bitplanes)
-level-1
-
-(addto-level level-1 'obj-3)
-level-1
-(remove-from-level level-1 'obj-3)
-
- (dl-find (level-start level-1)
- #'(lambda (node)
- (if (equal (dl-data node) 'obj-4)
- node
- nil)))
-
-(dl-list 'obj-1 'obj-2)
\ No newline at end of file
+(remove-from-bitplane (bitplanes) 'obj-10)
\ No newline at end of file
More information about the Corman-sdl-cvs
mailing list