aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorColin Okay <colin@cicadas.surf>2022-07-27 12:07:10 -0500
committerColin Okay <colin@cicadas.surf>2022-07-27 12:07:10 -0500
commit11f8d6dad0078464ccbc29cab57908a0923ca447 (patch)
treeff56d4daf1c2d7cb657587a9fcacdeedfef36307 /examples
parent0b743b90752bacf31923171af9af0e5ff1f08095 (diff)
[refactor] represent scene as a vector; [refactor] shared text shader
Diffstat (limited to 'examples')
-rw-r--r--examples/01-click-and-drag-image.lisp2
-rw-r--r--examples/09-ghoulspree.lisp12
2 files changed, 12 insertions, 2 deletions
diff --git a/examples/01-click-and-drag-image.lisp b/examples/01-click-and-drag-image.lisp
index e895d24..da6a12f 100644
--- a/examples/01-click-and-drag-image.lisp
+++ b/examples/01-click-and-drag-image.lisp
@@ -11,7 +11,7 @@
(ww::defhandler dragging-unit
(ww::on-mousemotion (app x y)
(let ((unit
- (first (ww::application-scene app))))
+ (elt (ww::application-scene app) 0)))
(setf (ww:x unit) x
(ww:y unit) y))))
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)