aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorColin Okay <colin@cicadas.surf>2022-07-29 08:10:08 -0500
committerColin Okay <colin@cicadas.surf>2022-07-29 08:10:08 -0500
commitff824c186ae3b24083feb909cdbe1fb571368c28 (patch)
tree19773b1a5b203585a28df78a06b9b1af4eaa5f8f
parent420b0fd1cbd1a3b38059a1997126f5797fb6ee76 (diff)
[example] altered to use drop-unit-if
-rw-r--r--examples/09-ghoulspree.lisp13
1 files changed, 2 insertions, 11 deletions
diff --git a/examples/09-ghoulspree.lisp b/examples/09-ghoulspree.lisp
index 896f470..33a5423 100644
--- a/examples/09-ghoulspree.lisp
+++ b/examples/09-ghoulspree.lisp
@@ -100,17 +100,8 @@ on which boundary VAL is outside of."
(loop for ghoul across (ww::application-scene app)
do (advance-pos ghoul)
when gravity
- do (apply-gravity-to ghoul accelleration)
- when (out-of-bounds-p ghoul)
- ;; note, it is generally a BadIdeaâ„¢ to delete
- ;; something from an array that you are iterating
- ;; over. It only works as expected here b/c of
- ;; implicit knowledge about the imlementation of the
- ;; scene container. A safer way in most cases would be
- ;; to `collect ghoul into drop-list` and then deleted
- ;; all the collected ghouls in a `finally` clause,
- ;; or to use ww::drop-unit-if in a `finally` clause.
- do (ww:drop-unit ghoul)))))
+ do (apply-gravity-to ghoul accelleration)))
+ (ww::drop-unit-if #'out-of-bounds-p)))
(defun random-sign ()
(if (zerop (random 2)) -1 1))