diff options
author | colin <colin@cicadas.surf> | 2024-12-14 12:29:29 -0800 |
---|---|---|
committer | colin <colin@cicadas.surf> | 2024-12-14 12:29:29 -0800 |
commit | 543704f0f54cbb1de78754ad8a323c482ab6829c (patch) | |
tree | 7528c0105516a2a2800e432de9f4f1a6c3fe506e /src/application.lisp | |
parent | 3a2217263d581be9a7f629b10d75aa8e3d581890 (diff) |
Diffstat (limited to 'src/application.lisp')
-rw-r--r-- | src/application.lisp | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/src/application.lisp b/src/application.lisp index f33bb9f..8c86fad 100644 --- a/src/application.lisp +++ b/src/application.lisp @@ -88,27 +88,33 @@ focus-table blur-table perframe-table)) (defmethod cleanup ((app application)) - (loop for asset being the hash-value of (application-assets app) - do (cleanup asset)) + ;; run cleanup on assets + (loop :for asset :being :the :hash-value :of (application-assets app) + :do (cleanup asset)) + ;; drop all current handlers (let ((listener (listener app))) (dolist (table +listener-table-slot-names+) (setf (slot-value listener table) (make-hash-table :synchronized t)))) - (loop for unit across (application-scene app) - do - (drop-unit unit) - (cleanup unit)) + + ;; then cleanup units + (loop :for unit :across (application-scene app) :do + (drop-unit unit) + (cleanup unit)) + + ;; finally run the exit hooks (pre-exit-hooks)) (defun run-perframe (app) "Runs all of the handlers objects listening for perframe events if they are in the scene." (let ((table (perframe-table (listener app))) (time (sdl2:get-ticks))) - (loop for target being the hash-key of table - for handlers = (slot-value (listener target) 'perframe) + (loop :for target :being :the :hash-key :of table + :for handlers := (slot-value (listener target) 'perframe) ;; only fire perframe when target is in scene - when (or (eq app target) (unit-in-scene-p target)) - do (loop for handler in handlers do (funcall handler target time))))) + :when (or (eq app target) (unit-in-scene-p target)) + :do (loop :for handler :in handlers + :do (funcall handler target time))))) (defmethod render ((app application)) (run-perframe app) @@ -119,7 +125,7 @@ (gl:blend-func :src-alpha :one-minus-src-alpha ) (with-slots (scene) app (when (plusp (length scene)) - (loop for unit across scene do (render unit)))) + (loop :for unit :across scene :do (render unit)))) (sdl2:gl-swap-window (application-window app)) (sleep (frame-wait app))) |