summaryrefslogtreecommitdiff
path: root/assets.lisp
diff options
context:
space:
mode:
authorBoutade <thegoofist@protonmail.com>2019-10-16 13:56:47 -0500
committerBoutade <thegoofist@protonmail.com>2019-10-16 13:56:47 -0500
commit31619ba2715d0b78b7b536f6412acd402d7096c8 (patch)
tree917bab16daabae57461466113c797b114e2faa33 /assets.lisp
parentb0729d564a92672c1a564cab7494acf832baa88f (diff)
basic emoting
Diffstat (limited to 'assets.lisp')
-rw-r--r--assets.lisp57
1 files changed, 52 insertions, 5 deletions
diff --git a/assets.lisp b/assets.lisp
index 823d99b..0df33a6 100644
--- a/assets.lisp
+++ b/assets.lisp
@@ -45,27 +45,64 @@
(:NAME "WalkRight1" :X 64 :Y 0 :WIDTH 64 :HEIGHT 128)
(:NAME "WalkRight2" :X 0 :Y 0 :WIDTH 64 :HEIGHT 128)))
+(defparameter +emoji-defs+
+'((:NAME "angry" :X 216 :Y 144
+ :WIDTH 72 :HEIGHT 72)
+ (:NAME "asshole" :X 216 :Y 216
+ :WIDTH 72 :HEIGHT 72)
+ (:NAME "breakdown" :X 288 :Y 0
+ :WIDTH 72 :HEIGHT 72)
+ (:NAME "chance" :X 72 :Y 216
+ :WIDTH 72 :HEIGHT 72)
+ (:NAME "death" :X 144 :Y 216
+ :WIDTH 72 :HEIGHT 72)
+ (:NAME "dollars" :X 0 :Y 288
+ :WIDTH 72 :HEIGHT 72)
+ (:NAME "food1" :X 144 :Y 72
+ :WIDTH 72 :HEIGHT 72)
+ (:NAME "food2" :X 144 :Y 144
+ :WIDTH 72 :HEIGHT 72)
+ (:NAME "food3" :X 216 :Y 0
+ :WIDTH 72 :HEIGHT 72)
+ (:NAME "food4" :X 72 :Y 144
+ :WIDTH 72 :HEIGHT 72)
+ (:NAME "food5" :X 0 :Y 216
+ :WIDTH 72 :HEIGHT 72)
+ (:NAME "incapacitated" :X 72 :Y 72
+ :WIDTH 72 :HEIGHT 72)
+ (:NAME "nauseated" :X 144 :Y 0
+ :WIDTH 72 :HEIGHT 72)
+ (:NAME "relaxed" :X 0 :Y 144
+ :WIDTH 72 :HEIGHT 72)
+ (:NAME "sick" :X 72 :Y 0
+ :WIDTH 72 :HEIGHT 72)
+ (:NAME "stressed" :X 0 :Y 72
+ :WIDTH 72 :HEIGHT 72)
+ (:NAME "very-angry" :X 0 :Y 0
+ :WIDTH 72 :HEIGHT 72)))
+
(defparameter +shared-faces+
(create-sprite-faces +tile-defs+))
+
+
(defparameter +nance-sheet-image+ "assets/Nance.png")
(defparameter +suit-sheet-image+ "assets/Suit.png")
(defparameter +nomry-sheet-image+ "assets/Normy.png")
(defparameter +things-look-up-track-path+ #P"assets/thingslookup.mp3")
(defparameter +cold-day-track-path+ #P"assets/coldday.mp3")
-
+(defparameter +emoji-sheet-image+ #P"assets/emoji.png")
(defvar *nance-texture*)
(defvar *suit-texture*)
(defvar *normy-texture*)
+(defvar *expression-texture*)
(defvar *harmony-initialized-p* nil)
(defvar *cold-day-track*)
(defvar *looking-up-track*)
(defvar *current-track*)
-
-
(defun boot-up-assets (renderer)
(with-surface-from-file (surf +nance-sheet-image+)
(setf *nance-texture* (sdl2:create-texture-from-surface renderer surf)))
@@ -76,6 +113,9 @@
(with-surface-from-file (surf +nomry-sheet-image+)
(setf *normy-texture* (sdl2:create-texture-from-surface renderer surf)))
+ (with-surface-from-file (surf +emoji-sheet-image+)
+ (setf *expression-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))
@@ -85,13 +125,20 @@
(harmony-simple:stop *cold-day-track*)
(setf *harmony-initialized-p* t)))
-
(defun free-assets ()
(harmony-simple:stop *current-track*)
+ (sdl2:destroy-texture *expression-texture*)
(sdl2:destroy-texture *nance-texture*)
(sdl2:destroy-texture *normy-texture*)
(sdl2:destroy-texture *suit-texture*))
+(defvar *expression-cache* (make-hash-table :test 'equal))
-
+(defun get-expression (expression)
+ "Returns a rect used as the render source in a call to RENDER-COPY"
+ (let ((exp (gethash expression *expression-cache*)))
+ (unless exp
+ (setf exp (find-tile-rect +emoji-defs+ expression))
+ (setf (gethash expression *expression-cache*) exp))
+ exp))