From 11f8d6dad0078464ccbc29cab57908a0923ca447 Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Wed, 27 Jul 2022 12:07:10 -0500 Subject: [refactor] represent scene as a vector; [refactor] shared text shader --- examples/01-click-and-drag-image.lisp | 2 +- examples/09-ghoulspree.lisp | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'examples') 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) -- cgit v1.2.3