aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples/09-ghoulspree.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/09-ghoulspree.lisp')
-rw-r--r--examples/09-ghoulspree.lisp12
1 files changed, 11 insertions, 1 deletions
diff --git a/examples/09-ghoulspree.lisp b/examples/09-ghoulspree.lisp
index b3c0106..a92299a 100644
--- a/examples/09-ghoulspree.lisp
+++ b/examples/09-ghoulspree.lisp
@@ -58,6 +58,16 @@ on which boundary VAL is outside of."
`(loop for (,a . ,more-a) on ,ls do
(loop for ,b in ,more-a do (progn ,@body)) )))
+(defmacro with-pairs ((a b) vector &rest body)
+ (alexandria:with-gensyms (idxa idxb vec)
+ `(loop
+ with ,vec = ,vector
+ for ,idxa from 0 to (- (length ,vec) 2)
+ for ,a = (aref ,vec ,idxa) do
+ (loop for ,idxb from (1+ ,idxa) to (1- (length ,vec))
+ for ,b = (aref ,vec ,idxb) do
+ (progn ,@body)))))
+
(defun handle-collision (g1 g2 &optional (friction 0.99))
(with-slots ((dx1 dx) (dy1 dy) (dr1 dr)) g1
(with-slots ((dx2 dx) (dy2 dy) (dr2 dr)) g2
@@ -93,7 +103,7 @@ on which boundary VAL is outside of."
(gravity-on-p app))
(accelleration
(/ 9.8 (ww:fps app))))
- (loop for ghoul in (ww::application-scene app)
+ (loop for ghoul across (ww::application-scene app)
do (advance-pos ghoul)
when gravity
do (apply-gravity-to ghoul accelleration)