diff options
author | Colin Okay <colin@cicadas.surf> | 2022-07-27 12:07:10 -0500 |
---|---|---|
committer | Colin Okay <colin@cicadas.surf> | 2022-07-27 12:07:10 -0500 |
commit | 11f8d6dad0078464ccbc29cab57908a0923ca447 (patch) | |
tree | ff56d4daf1c2d7cb657587a9fcacdeedfef36307 /examples/09-ghoulspree.lisp | |
parent | 0b743b90752bacf31923171af9af0e5ff1f08095 (diff) |
[refactor] represent scene as a vector; [refactor] shared text shader
Diffstat (limited to 'examples/09-ghoulspree.lisp')
-rw-r--r-- | examples/09-ghoulspree.lisp | 12 |
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) |