From f1e29e1ac5cfa52463f69c21bcc10f0ba15d6514 Mon Sep 17 00:00:00 2001 From: annabunches Date: Thu, 5 Oct 2023 15:26:31 -0400 Subject: [PATCH] Animate transition into and out of defend mode. --- src/entity.lua | 2 ++ src/images/kani/defend-table-1.png | Bin 0 -> 562 bytes src/images/kani/defend-table-2.png | Bin 0 -> 525 bytes src/images/kani/defend-table-3.png | Bin 0 -> 499 bytes src/images/kani/defend-table-4.png | Bin 0 -> 442 bytes src/images/kani/defend-table-5.png | Bin 0 -> 365 bytes src/images/kani/defend-table-6.png | Bin 0 -> 322 bytes src/images/kani/defend-table-7.png | Bin 0 -> 314 bytes src/images/kani/defend-table-8.png | Bin 0 -> 285 bytes src/images/{kani.png => kani/static.png} | Bin src/kani.lua | 17 ++++++++++++++--- 11 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 src/images/kani/defend-table-1.png create mode 100644 src/images/kani/defend-table-2.png create mode 100644 src/images/kani/defend-table-3.png create mode 100644 src/images/kani/defend-table-4.png create mode 100644 src/images/kani/defend-table-5.png create mode 100644 src/images/kani/defend-table-6.png create mode 100644 src/images/kani/defend-table-7.png create mode 100644 src/images/kani/defend-table-8.png rename src/images/{kani.png => kani/static.png} (100%) diff --git a/src/entity.lua b/src/entity.lua index 648dec8..c4a78a3 100644 --- a/src/entity.lua +++ b/src/entity.lua @@ -83,6 +83,8 @@ end -- animate the entity based on the passed in imageTable. If reverse is true, play the -- animation backwards. duration is how long the animation should be in total +-- TODO: it would be nice to be able to reverse the *current* animation without +-- starting all the way over at the beginning... function Entity:animate(imgTable, duration, reverse) self.animationTable = imgTable local startValue = 1 diff --git a/src/images/kani/defend-table-1.png b/src/images/kani/defend-table-1.png new file mode 100644 index 0000000000000000000000000000000000000000..26d786b034d5c92bbe1ba29102807287ee212b7c GIT binary patch literal 562 zcmV-20?qx2P)Px$>`6pHR9HvdSkV%LAPk%T|IypI8(yhRlPWs4J?#`rNYhYQ9@_6|hArkldXA#n z@okKa*L??HxacFmMZnf+z77rnOW8xHTd?;240BoPQ(24x$Ks&$c}BZ9EU3y{6h|!< zIBpFZy{ta-;8b8ub6!U8=M`}4ct2?rv|!v2UwZC4uvFTY#vNy*{hJ zcD91jYCX6LCe%-|5y6U8z0!RB%&8+ za0MU()})e|_kzsRYq0_>?KD1t)|6%oc&9vb_9`Gho=wi!ea;FlWX^9<-(YXED%MS0 z2`(y%&O@(EYue?SRomj|3T1?CsO+)=*u{xVSe>joZc1=vP+kv5_fLhrsllm*0W~+; z-y%lK4E~IjwAGH(A7jfm0I3O&PVbS;A8ucFvG%_$({#-yJH0E0Tk$lM+MVXmk?xEJ zl}h#9c!y*9qoHyTj_yaIg(*BDWDsyOZ z#$ak=Y>SCjh|aod>f{#wE^t{B3o+aY4grK1ULzsAE12WTP5=M^07*qoM6N<$f_WwT AO8@`> literal 0 HcmV?d00001 diff --git a/src/images/kani/defend-table-2.png b/src/images/kani/defend-table-2.png new file mode 100644 index 0000000000000000000000000000000000000000..4627733b5843597d61f13c34fb2f4851506e697a GIT binary patch literal 525 zcmV+o0`mQdP)Px$$4Nv%R9HvdSX&Zyufn6jK-vivMk^o)@WIAz#)L@-_yXc ztU~dKz{cj073K6IjzU!7RaeUlqOeG7Zmim@Bq%WPoPo2lTeXyttd$IPLGRjE9Z$W$ zSX*3lvckVP8|g;Zt?vXED|~AbDE2b9!j7WSeKfeNZNVOUX3W_WFJgcVfk#i!_9G}xSyo!(6ap97%G#XzmvsiF ze={;YdXd8(-fYXnvNn55?5ct58dYkn^+K=?d#akT&?YIefefe$U^AB$*H&vp#iit_)&+E6S5R&>Gnj{D!NwN7zD@-4QTEQ73Zok=pPx$tw}^dR9Hvlm{|_PAPhvC`yaYhsvq$+s#%a zfLSmr6s)8P>#TN#7hf!#Rw}!N^hgS)t9Jvm8aE0#6%K`nB!q0nP_Pn0!!fs_Lkt&TYeFH6bP_FXUzLebHkDLDS=srU!=|=c zMR`F6OUs(4Ve>W@9IGbv#-le}M#g|G=ehe5m+I`9!n@%weU6A;kfuN6cpboVU)F|@ z1cUnRUpyXK_f%^%_u>({eML<^dW-Ww&==3I!bM%kH3$@#pVe^j6!O*u3f2h=b_{h^ pXQA{_!h?XcE_wk8$cDmU`xm}Ao-wtvR1g3F002ovPDHLkV1g{<-ckSn literal 0 HcmV?d00001 diff --git a/src/images/kani/defend-table-4.png b/src/images/kani/defend-table-4.png new file mode 100644 index 0000000000000000000000000000000000000000..b5fc32fe01fde88b75618acacdff31b910903916 GIT binary patch literal 442 zcmV;r0Y(0aP)Px$bV)=(R9HvdnBfk?AP9ul_kZXuW^o}D+rPD_pLdAbS?&d{D3=B|N_73)%O}rfs+?G}(`s7v3R!KkZ&^}2w@$Vq${|29M#J^O zd^?;3XcM&0g27+^IL}_)fVy7Nw3Gh*HnX1v- z)lBvZFstsl3qjAS8jRYuu7nFOict}Ur3V7Hh6^tYy$1q9ghOZrD|d*nVzY*sE0Px$CrLy>R9Hvtn9&ZyAP7a<|NrPUK9~^-7A|6F>Ylbl=HYU&mh&k5ISaEL8xE~b zrgA?51?>X`8I>ptN5NVykO)xFgK`{f!!-pgKI&^)Rp@u4RsYK@WtBGTrIKLF!g1JT z%6ZE&y{ua1UNByEi+yf;@Ss_65Dcdq!69n(n9^|Y!Alj%QZ5CKAGDFuh5;pSNY6$T zGUUC?vWA<3!p&4nQrfLz56A|C{I>$mtr+)1rgEj>;Kq1GL-g!2${Q{#ZT*>mFqqcf zW#P(zNy>c!F61@s?0L;KoxVLGSElK2UlIiB!=-RsNzZS{gO;Gu;|T5Pp(VC-R^n}j zJ)iR`Ho81my!|*Ui2(6f%b;<%AC!?XgVJ!u9Q0+G%5Au?0_Y!H`nE(dz@rP{00000 LNkvXXu0mjf{4k-5 literal 0 HcmV?d00001 diff --git a/src/images/kani/defend-table-6.png b/src/images/kani/defend-table-6.png new file mode 100644 index 0000000000000000000000000000000000000000..38376ffbf6f14f56b0639691ab0b140ad72e2205 GIT binary patch literal 322 zcmV-I0lof-P)Px#{7FPXR9Hvtmq8B0FbD*b|3A7_50Q`)hxIPBq@vdtJPg>C_pR`6FU+8!31K+i+kPPs@I0&fD02|4>U~g9MKot{6q~PxE=f3Rt>17S1agvOi10 zLLHlyhLc-5OQ2c{vv;LG3Qo57D7Z*#a(k`03^03TET7;bARCODzi+@T8yn{#(_Cpd z`d~cbKpfR&v{!DcJ@S!&G+6e3D|LN%7h{w;$=Y3I5rAdkWH4kVSc9eE=!@4o5aZ*6 zwTE=(_Mx+?zuco5dd8VWUIB2vRdYz?(UW`Ir9ZT(AgZ&-dL UF{x!E8UO$Q07*qoM6N<$f|aX-IsgCw literal 0 HcmV?d00001 diff --git a/src/images/kani/defend-table-7.png b/src/images/kani/defend-table-7.png new file mode 100644 index 0000000000000000000000000000000000000000..178aa32688af811273e253e98947559518131e21 GIT binary patch literal 314 zcmV-A0mc4_P)Px#^hrcPR9HvtnA;A8FbD+o|36w|Vv{D?0=uASIIqXjVYV0Jx+MOsiP@HdL(?g9 zWezofj;l47$=r6r(5YApw26=T@5W01n00CSgfoyH+#}?pjsP~hp2cz1?LrMFB7)c4~zh#ARAmX7_@tzfTLrLG?y9< zKKDMcAzF74@zSyOTiz282GhLF{`UH!tj!Kak7(1v(O{Y@1vQu&PSd!!*)$!#W={h* zIs>H_Rcq~wNxHyIHm`k-5Z8(40}Px#*GWV{R9Hvtmq8AIFbD+k|Bu#qXu?75x-142&n-*`XyamqzojsnH5^-=HrM7@ z1MI%;xi)8JtFw^a5=a6MbX6fF)~yQ90-|6(=`1D;I19wU?a60xA;7aBEYwI^8ct&G z=!8*gGJBbDVSBHFQmkmbs-xF~3o%ee<`rdoRK#bF63`V%;{KzW- zX|S{L{smmf+SSFVuvZo?42C=@tiiHy5-`Nvz6P}?gJPeQazEA3Z(PPAc`1~T4aeGS jb8U__!0zjw`=q%IPoWwyT=7N^00000NkvXXu0mjfR=jq5 literal 0 HcmV?d00001 diff --git a/src/images/kani.png b/src/images/kani/static.png similarity index 100% rename from src/images/kani.png rename to src/images/kani/static.png diff --git a/src/kani.lua b/src/kani.lua index fe00ac6..f9768bf 100644 --- a/src/kani.lua +++ b/src/kani.lua @@ -44,11 +44,17 @@ local SPEED_SIZE_LOOKUP = { [4] = 1, } +-- animations table +local animations = { + defend=gfx.imagetable.new("images/kani/defend") +} + + class("Kani").extends(Entity) function Kani:init(ui) - Kani.super.init(self, gfx.image.new("images/kani.png"), 100) + Kani.super.init(self, gfx.image.new("images/kani/static.png"), 100) self.type = 'kani' self:setGroupMask(0x2) @@ -96,6 +102,9 @@ function Kani:chargeShot() end function Kani:setReserveCharge(newCharge) + if newCharge < 0 then + newcharge = 0 + end self.reserveCharge = newCharge self.ui.chargeMeter:setValue(self.reserveCharge) end @@ -165,7 +174,7 @@ function Kani:runReady() self:fire() end - if playdate.buttonIsPressed(playdate.kButtonB) then + if playdate.buttonIsPressed(playdate.kButtonB) and self.reserveCharge > 0 then self.fsm:changeState("DEFEND") end @@ -178,14 +187,16 @@ end function Kani:onDefend() self.armor = 5 + self:animate(animations.defend, 500) end function Kani:onDefendExit() self.armor = 0 + self:animate(animations.defend, 500, true) end function Kani:runDefend() - if not playdate.buttonIsPressed(playdate.kButtonB) then + if self.reserveCharge == 0 or not playdate.buttonIsPressed(playdate.kButtonB) then self.fsm:changeState("READY") return end