From 4641997e0f89cdda9ef4b3c17c0a30888b6908f2 Mon Sep 17 00:00:00 2001 From: Boutade Date: Fri, 11 Oct 2019 15:21:35 -0500 Subject: Nance walk animations --- assets.lisp | 46 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) (limited to 'assets.lisp') diff --git a/assets.lisp b/assets.lisp index 0adf417..37d05d3 100644 --- a/assets.lisp +++ b/assets.lisp @@ -1,14 +1,51 @@ +;;;; assets.lisp (in-package #:the-price-of-a-cup-of-coffee) +;;; Utility Functions + +(defun make-source-rects (tile-defs) + "Accepts a TILE-DEFS list and adds an SDL2:RECT instance to each keyed to :RECT" + (mapcar + (lambda (tl) + (list* :rect + (sdl2:make-rect (getf tl :x) + (getf tl :y) + (getf tl :width) + (getf tl :height)) + tl)) + tile-defs)) + +(defun find-tile-rect (tile-defs name) + "Return the rect for the tile with NAME in TILE-DEFS list." + (let-when (tl (find name tile-defs + :key (lambda (tl) (getf tl :name)) + :test #'string-equal)) + (getf tl :rect))) + +(defun select-tile-rects (tile-defs &rest names) + (map 'vector ($ #'find-tile-rect tile-defs _) names)) + + +(defun create-sprite-faces (defs) + (list :facing-down (select-tile-rects defs "front") + :walking-down (select-tile-rects defs "front" "walkforward1" "front" "walkforward2") + :facing-up (select-tile-rects defs "back") + :walking-up (select-tile-rects defs "back" "walkback1" "back" "walkback2") + :facing-left (select-tile-rects defs "profileleft") + :walking-left (select-tile-rects defs "profileleft" "walkleft1" "profileleft" "walkleft2") + :facing-right (select-tile-rects defs "profileright") + :walking-right (select-tile-rects defs "profileright" "walkright1" "profileright" "walkright1"))) + +;;; Nance Assets (defparameter +nance-sheet-image+ "assets/Nance.png") -(defparameter +nance-tiles+ +(defvar *nance-tile-defs* '((:NAME "Back" :X 256 :Y 128 :WIDTH 64 :HEIGHT 128) (:NAME "Front" :X 320 :Y 0 :WIDTH 64 :HEIGHT 128) - (:NAME "ProfileLeft" :X 192 :Y 128 :PATH :WIDTH 64 :HEIGHT 128) - (:NAME "ProfileRight" :X 256 :Y 0 :PATH :WIDTH 64 :HEIGHT 128) + (:NAME "ProfileLeft" :X 192 :Y 128 :WIDTH 64 :HEIGHT 128) + (:NAME "ProfileRight" :X 256 :Y 0 :WIDTH 64 :HEIGHT 128) (:NAME "WalkBack1" :X 64 :Y 128 :WIDTH 64 :HEIGHT 128) (:NAME "WalkBack2" :X 128 :Y 128 :WIDTH 64 :HEIGHT 128) (:NAME "WalkForward1" :X 0 :Y 256 :WIDTH 64 :HEIGHT 128) @@ -19,3 +56,6 @@ (:NAME "WalkRight2" :X 0 :Y 0 :WIDTH 64 :HEIGHT 128))) + + + -- cgit v1.2.3