From ff824c186ae3b24083feb909cdbe1fb571368c28 Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Fri, 29 Jul 2022 08:10:08 -0500 Subject: [example] altered to use drop-unit-if --- examples/09-ghoulspree.lisp | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'examples/09-ghoulspree.lisp') 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)) -- cgit v1.2.3