diff options
-rw-r--r-- | assets.lisp | 8 | ||||
-rw-r--r-- | the-price-of-a-cup-of-coffee.lisp | 40 |
2 files changed, 26 insertions, 22 deletions
diff --git a/assets.lisp b/assets.lisp index f08919f..7109559 100644 --- a/assets.lisp +++ b/assets.lisp @@ -73,6 +73,9 @@ (with-surface-from-file (surf +suit-sheet-image+) (setf *suit-texture* (sdl2:create-texture-from-surface renderer surf))) + (with-surface-from-file (surf +nomry-sheet-image+) + (setf *normy-texture* (sdl2:create-texture-from-surface renderer surf))) + (unless *harmony-initialized-p* (harmony-simple:initialize) (setf *looking-up-track* (harmony-simple:play +things-look-up-track-path+ :music :loop t)) @@ -83,7 +86,10 @@ (setf *harmony-initialized-p* t))) - +(defun free-assets () + (sdl2:destroy-texture *nance-texture*) + (sdl2:destroy-texture *normy-texture*) + (sdl2:destroy-texture *suit-texture*)) diff --git a/the-price-of-a-cup-of-coffee.lisp b/the-price-of-a-cup-of-coffee.lisp index f04908e..891d702 100644 --- a/the-price-of-a-cup-of-coffee.lisp +++ b/the-price-of-a-cup-of-coffee.lisp @@ -177,10 +177,7 @@ (defun boot-up (renderer) - (boot-up-assets renderer) - - (setf *nance* (make-instance 'hero :sheet *nance-texture*))) @@ -391,30 +388,31 @@ (defun start () ;; (play-track *cold-day-track*) + (unwind-protect + (sdl2:with-init (:everything) + (sdl2:with-window (win :w 1024 :h 600 :title "The Price Of A Cup Of Coffee" :flags '(:shown)) + (sdl2:with-renderer (renderer win :flags '(:accelerated)) - (sdl2:with-init (:everything) - (sdl2:with-window (win :w 1024 :h 600 :title "The Price Of A Cup Of Coffee" :flags '(:shown)) - (sdl2:with-renderer (renderer win :flags '(:accelerated)) - - (boot-up renderer) + (boot-up renderer) - (sdl2:with-event-loop (:method :poll) + (sdl2:with-event-loop (:method :poll) - (:keydown (:keysym keysym) - (if (sdl2:scancode= (sdl2:scancode-value keysym) :scancode-escape) - (sdl2:push-event :quit) - (handle-keydown keysym))) + (:keydown (:keysym keysym) + (if (sdl2:scancode= (sdl2:scancode-value keysym) :scancode-escape) + (sdl2:push-event :quit) + (handle-keydown keysym))) - (:keyup (:keysym keysym) (handle-keyup keysym)) + (:keyup (:keysym keysym) (handle-keyup keysym)) - (:idle () - (update :game (sdl2:get-ticks)) - (render :game renderer) + (:idle () + (update :game (sdl2:get-ticks)) + (render :game renderer) - (sdl2:delay +frame-delay+)) + (sdl2:delay +frame-delay+)) - (:quit () -; (harmony-simple:stop *current-track*) - t)))))) + (:quit () + ; (harmony-simple:stop *current-track*) + t))))) + (free-assets))) |