From 54f6a46428cb3608b54ca494236b6ded48b043ab Mon Sep 17 00:00:00 2001 From: lustlion Date: Thu, 24 Feb 2022 04:15:35 +0100 Subject: [PATCH] added draw functions for setScale, rehandled scale, animations now have multiple frame times (this breaks some minor stuff) --- assets/entities/cursed_book/flying2.png | Bin 140 -> 146 bytes assets/entities/cursed_book/flying3.png | Bin 146 -> 120 bytes assets/entities/cursed_book/flying4.png | Bin 146 -> 143 bytes assets/entities/cursed_book/flying5.png | Bin 120 -> 137 bytes assets/entities/cursed_book/flying7.png | Bin 137 -> 120 bytes assets/entities/cursed_book/flying8.png | Bin 143 -> 146 bytes assets/entities/kupo/kupo1.png | Bin 203 -> 310 bytes assets/entities/kupo/kupo2.png | Bin 198 -> 295 bytes assets/entities/kupo/kupo3.png | Bin 201 -> 304 bytes assets/entities/kupo/kupo4.png | Bin 199 -> 291 bytes code/animation.lua | 17 ++- code/canvas.lua | 2 +- code/debug.lua | 4 + code/draw.lua | 6 + code/game.lua | 2 +- code/gameworld.lua | 2 +- code/menu.lua | 8 +- code/require.lua | 1 + data/animations.lua | 150 ++++++++++++++++++------ 19 files changed, 139 insertions(+), 53 deletions(-) create mode 100644 code/draw.lua diff --git a/assets/entities/cursed_book/flying2.png b/assets/entities/cursed_book/flying2.png index 2d924b4281e3a7c3809a97ac0f6302a943e35060..82b5b273383cdfa67508a0b1e92a437940c716a7 100644 GIT binary patch delta 104 zcmV-u0GI!a0g?fbF=0$eL_t(2k>!uE4Ztu61n*hM`;Xy;{3${tgPbCDPND$rg@BK! z57xwcAEP?zVhphFj3m}P1XF$rC%HD@ez`U^P@H)C<$(6Uuebn4iYAZ1=uLnC0000< KMNUMnLSTY+Y%UN0 delta 98 zcmV-o0GHTM5fJh=~V8EvdE{LW9MUDwc5Vu>A4@Bgg@mIAKH6LNk|x&{`t=@n3R%o_h(9ispM delta 103 zcmV-t0GR)Hk^zu0VN6LxK~yM_<&Uuqz%U2|?^($EkKu*TlYDCAL9MJai5KMUI!y3v}% zE6h=4${xWd)~s92(}&|001;1zq@Qn`6LYXA#Oe`u`UCxJC&LZg5hlLv00000NkvXX Hu0mjfjQuMH delta 104 zcmV-u0GI!d0g?fbF=0$eL_t(2k>!uE4Ztu61n*hM`;Xy;{3${tgPbCDPND$rg@BK! z57xwcAEP?zVhphFj3m}P1XF$rC%HD@ez`U^P@H)C<$(6Uuebn4iYAZ1=uLnC0000< KMNUMnLSTY-q%IQx diff --git a/assets/entities/cursed_book/flying5.png b/assets/entities/cursed_book/flying5.png index c9dcb7f00d1728538fddf69b471d01ed11b2a9e9..ad457995d88b9adbca55e8ad0230d258955168b0 100644 GIT binary patch delta 94 zcmb>EWSn3a;q2++7@{#TIYDC1gZr*+|NrY5{ZV(DC#dyJUhCii5Lm)5*shs$sr_|o wN{R#P3#o@(AFV#xizG}=KD4^n!DIpt!@;96mca*3NHPF{r>mdKI;Vst0HzWriU0rr delta 77 zcmeBVte9ZvZsh6W7@{#TIbnfm!k_Yq5A8jrBqR(>|NQ3{OiD>Pa^V2e)s}_qCmlo% hxO5f2Sez)p#PEZM{r2IwRtp9o@O1TaS?83{1OS>n9hv|D diff --git a/assets/entities/cursed_book/flying7.png b/assets/entities/cursed_book/flying7.png index ad457995d88b9adbca55e8ad0230d258955168b0..c9dcb7f00d1728538fddf69b471d01ed11b2a9e9 100644 GIT binary patch delta 77 zcmeBVte9ZvZsh6W7@{#TIbnfm!k_Yq5A8jrBqR(>|NQ3{OiD>Pa^V2e)s}_qCmlo% hxO5f2Sez)p#PEZM{r2IwRtp9o@O1TaS?83{1OS>n9hv|D delta 94 zcmb>EWSn3a;q2++7@{#TIYDC1gZr*+|NrY5{ZV(DC#dyJUhCii5Lm)5*shs$sr_|o wN{R#P3#o@(AFV#xizG}=KD4^n!DIpt!@;96mca*3NHPF{r>mdKI;Vst0HzWriU0rr diff --git a/assets/entities/cursed_book/flying8.png b/assets/entities/cursed_book/flying8.png index 9bddff8ec3052bd17cd29f9062bb857f064c3042..82b5b273383cdfa67508a0b1e92a437940c716a7 100644 GIT binary patch delta 104 zcmV-u0GI!d0g?fbF=0$eL_t(2k>!uE4Ztu61n*hM`;Xy;{3${tgPbCDPND$rg@BK! z57xwcAEP?zVhphFj3m}P1XF$rC%HD@ez`U^P@H)C<$(6Uuebn4iYAZ1=uLnC0000< KMNUMnLSTY-q%IQx delta 101 zcmV-r0Gj`j0gnNYFTlYDCAL9MJai5KMUI!y3v}% zE6h=4${xWd)~s92(}&|001;1zq@Qn`6LYXA#Oe`u`UCxJC&LZg5hlLv00000NkvXX Hu0mjfjQuMH diff --git a/assets/entities/kupo/kupo1.png b/assets/entities/kupo/kupo1.png index 7c2bb4232a7ece1c5fed68f5f70be29c1b92eca2..aaf4ff5f804b408c390df72840909584ee896acc 100644 GIT binary patch delta 270 zcmV+p0rCFJ0k#5=F@Nw$L_t(IjkQucj>0eyeUpM_4*&ph0|5OI8S~%oI{#&oaDR`379B)GGsaBR+=*R_ z&@AP_CdJ(kvclmMhPqJ`X$4XeSgf-%AC6I?3(^Yk@#)Y0el$|bUPLR&LMd^#uD*Mt zvDsReMv7IFy;8UqaM#-R(b8`&}Vu2lX{xYXe|E&uHuWhhOJ=x%!nPE-CK|*LR99EU72EBi`cL-3lKM zO2fTfGeS#IP1DS)h8Dv26DjGu)~?_HTn*ZK>~k+FuW0kCoB#QYn`^$30*-E{A%N5F@JzbL_t(Ijm=U)62LG7q?7mf|2NVHMGtLK1a<7*B&=Nk{2HSJ zTiBc#N8Q>~@q$1rpTZaH`CXWt`#LKhW%^_6} zQprl7m&YS$S%=ChL!YuZQ=t?@u(rzhS|LF3l(Si+r!4(OcNTF0`Ceghi?U5$00000 LNkvXXu0mjfnutQ# diff --git a/assets/entities/kupo/kupo3.png b/assets/entities/kupo/kupo3.png index caa2541cf88908d5e8cec870c2b9e4632d076b48..ffbf849f88b8de64137f30b671ebc2a6e82701cd 100644 GIT binary patch delta 264 zcmV+j0r&pN0k8s)F@NewL_t(IjkQuM4#H3nob3@Xz!^x2$HNIIN9Z+P(42(SVo-G$ zR4b|>m`X@Z)h?o+_g?=AVUkT&?9T4YF7P90tbij(l{@S4`l_jJHc^p@)SPg}CQGb` zk}C!2I~bO5J^|iNuik}0Ir}XDK#FZe%=~`!!Ktz(h=>)djejm6A}hb#mT(qFdtz-; z7J{=7rfFsK{2(oS685BBPRTaNnkh3d;sj(JG{ delta 160 zcmV;R0AK&G0?7f8F@J+eL_t(IjkQu+5`Z8GTo})j_diA*DElZ135lj@|8(33vcR8M zXEY1@h9h#uWGEnL3-xD{qGVh=5h9|&b3;~+-XDAhX=RBua`Ivq;F?j0dS;s9)C>Sz zk0gpHcTYIis0my_(gQ8(jn=Jk7r7hTHKvhSVXDeet-~towHc+G_ZAyzhg9R3>*qoM O0000Tz z5QHd;9a&3|ddy`K5WqT!Ca?ckOF)PMc;ARG46bo$(yx&uZCk=tfPEHj-Q=)M?&g>2 zUup7uBppC+!ihA;A59pd2t+*VkG+9yvDF6Tf07*qoM6N<$f`A5a AhyVZp delta 158 zcmV;P0Ac^50>=T6F@J$cL_t(IjkQui4!|G`60`Sg|9{4OknChuD{6NbHxmnmlG2~3 zccO>?lUKtLktsm~3;MU);)tjy5&)Qdcf&?eWw0IEVX#1wERZB>?P-WC7`!WV1Wg@h z*n!@_lGrVjEqTU#CDa>l`T;9aA#%dbf=$_0c~$FWl`Uboc^6;t0GY&K=JYFvjQ{`u M07*qoM6N<$f~`MAlmGw# diff --git a/code/animation.lua b/code/animation.lua index 766cf04..4e6b23c 100644 --- a/code/animation.lua +++ b/code/animation.lua @@ -5,7 +5,6 @@ function Animation:New(anim_data) o.path = anim_data.path o.frames = anim_data.frames - o.speed = anim_data.speed o.imgs = anim_data.imgs o.subframe = 0 o.frame = 1 @@ -26,8 +25,8 @@ end -- to manually handle what frame function Animation:DrawFrame(frame, x, y, rotate, sx, sy) - if frame > self.frames then - frame = self.frames + if frame > #self.frames then + frame = #self.frames end local x = x or 0 local y = y or 0 @@ -45,18 +44,18 @@ end -- to linearly animate function Animation:Animate() - if self.speed ~= 0 then + if self.frames[self.frame] ~= 0 then -- try to animate self.subframe = self.subframe + current_dt - if self.subframe > self.speed then - self.frame = self.frame + 1 - self.subframe = self.subframe - self.speed + if self.subframe > self.frames[self.frame] then + self.subframe = self.subframe - self.frames[self.frame] + self.frame = self.frame + 1 end -- cycle - if self.frame >= self.frames+1 then - self.frame = self.frame - self.frames + if self.frame >= #self.frames+1 then + self.frame = self.frame - #self.frames end end end diff --git a/code/canvas.lua b/code/canvas.lua index e75d64b..42722b7 100644 --- a/code/canvas.lua +++ b/code/canvas.lua @@ -14,7 +14,7 @@ end function Canvas:Recreate() self.canvas:release() - self = Canvas:New() + self = Canvas:New(self.name) end function Canvas:Reset() diff --git a/code/debug.lua b/code/debug.lua index f2951d4..e3ccc73 100644 --- a/code/debug.lua +++ b/code/debug.lua @@ -1,4 +1,6 @@ function DebugUI() + love.graphics.setScale() + local mouse_x, mouse_y = love.mouse.getPosition() for _, light in pairs(LoadedObjects.Lights) do love.graphics.print(light.pos.x,light.pos.x,light.pos.y) @@ -24,11 +26,13 @@ function DebugUI() end function DebugColisions() + love.graphics.setScale(game.scale) -- DrawColisionTable() LoadedObjects.DrawCollisions() end function DebugEntities() + love.graphics.setScale(game.scale) for _, particle in pairs(LoadedParticles) do particle:Debug() end diff --git a/code/draw.lua b/code/draw.lua new file mode 100644 index 0000000..7bce9dd --- /dev/null +++ b/code/draw.lua @@ -0,0 +1,6 @@ +function love.graphics.setScale(scale_x, scale_y) + local scale_x = scale_x or 1 + local scale_y = scale_y or scale_x + love.graphics.origin() + love.graphics.scale(scale_x,scale_y) +end diff --git a/code/game.lua b/code/game.lua index 4d543b8..6113872 100644 --- a/code/game.lua +++ b/code/game.lua @@ -87,7 +87,7 @@ function GameDraw() GameworldDrawEnd() -- hud - textScale = 0.5 + textScale = 1 -- debug if debug then DebugUI() end diff --git a/code/gameworld.lua b/code/gameworld.lua index e8f0f10..79f2324 100644 --- a/code/gameworld.lua +++ b/code/gameworld.lua @@ -5,7 +5,7 @@ function GameworldDrawPrepare() Canvas.Darkness.Recreate() end pcr, pcg, pcb, pca = love.graphics.getColor() - love.graphics.scale(game.scale,game.scale) + love.graphics.setScale(game.scale,game.scale) love.graphics.setColor(1,1,1,1) end diff --git a/code/menu.lua b/code/menu.lua index 25b0c79..125cb1b 100644 --- a/code/menu.lua +++ b/code/menu.lua @@ -1,8 +1,9 @@ function MenuDraw(menu) local font = love.graphics.getFont() love.graphics.setFont(LocaleFont) - -- Set scale to 1 - love.graphics.scale(0.5,0.5) + + -- reset scale + love.graphics.setScale() if menu == "pause" then MenuDrawPauseScreen() @@ -13,8 +14,7 @@ function MenuDraw(menu) for _, element in pairs(UIElement) do element:Draw() end - -- Reset scale - love.graphics.scale(2,2) + love.graphics.setFont(font) end diff --git a/code/require.lua b/code/require.lua index 54282e0..2cf548d 100644 --- a/code/require.lua +++ b/code/require.lua @@ -8,6 +8,7 @@ require "code/locale" -- support functions require "code/math" +require "code/draw" require "code/hex" require "code/in_out" diff --git a/data/animations.lua b/data/animations.lua index 826bf14..7f821e3 100644 --- a/data/animations.lua +++ b/data/animations.lua @@ -5,118 +5,194 @@ animation = {} animation.cursed_book = {} animation.cursed_book.attack_loop = { path = "assets/entities/cursed_book/attack_loop", - frames = 1, - speed = 0 + frames = { + 0 + } } animation.cursed_book.attack_transition = { path = "assets/entities/cursed_book/attack_transition", - frames = 5, - speed = 1/16 + frames = { + 1/16, + 1/16, + 1/16, + 1/16, + 1/16 + } } animation.cursed_book.flying = { path = "assets/entities/cursed_book/flying", - frames = 11, - speed = 1/16 + frames = { + 2/16, + 2/16, + 1/16, + 1/16, + 1/16, + 1/16, + 1/16, + 2/16 + } } animation.cursed_book.spawn = { path = "assets/entities/cursed_book/spawn", - frames = 5, - speed = 0 + frames = { + 0, + 0, + 0, + 0, + 0 + } } -- particles animation.particle = {} animation.particle.simple = { path = "assets/entities/particle/simple", - frames = 4, - speed = 1/4 + frames = { + 1/4, + 1/4, + 1/4, + 1/4 + } } -- fairy animation.fairy = {} animation.fairy.flying = { path = "assets/entities/fairy/flying", - frames = 2, - speed = 1/30 + frames = { + 1/32, + 1/32 + } } -- decoration animation.decoration = {} animation.decoration.candelabra = { path = "assets/entities/decoration/candelabra", - frames = 8, - speed = 1/6 + frames = { + 1/8, + 1/8, + 1/8, + 1/8, + 1/8, + 1/8, + 1/8, + 1/8 + } } -- kupo animation.kupo = {} animation.kupo.body = { path = "assets/entities/kupo/kupo", - frames = 4, - speed = 1/8 + frames = { + 1/8, + 1/8, + 1/8, + 1/8 + } } animation.kupo.bow = { path = "assets/entities/kupo/kupo_bow", - frames = 6, - speed = 1/10 + frames = { + 1/10, + 1/10, + 1/10, + 1/10, + 1/10, + 1/10 + } } animation.kupo.arrow = { path = "assets/entities/kupo/kupo_arrow", - frames = 1, - speed = 0 + frames = { + 0 + } } -- moth mask animation.moth_mask = {} animation.moth_mask.idle = { path = "assets/entities/nancy/moth_mask/idle", - frames = 4, - speed = 1/8 + frames = { + 1/8, + 1/8, + 1/8, + 1/8 + } } animation.moth_mask.run = { path = "assets/entities/nancy/moth_mask/run", - frames = 6, - speed = 1/8 + frames = { + 1/8, + 1/8, + 1/8, + 1/8, + 1/8, + 1/8 + } } animation.moth_mask.fall = { path = "assets/entities/nancy/moth_mask/fall", - frames = 3, - speed = 1/8 + frames = { + 1/8, + 1/8, + 1/8 + } } animation.moth_mask.jump = { path = "assets/entities/nancy/moth_mask/jump", - frames = 3, - speed = 1/8 + frames = { + 1/8, + 1/8, + 1/8 + } } -- nancy animation.nancy = {} animation.nancy.idle = { path = "assets/entities/nancy/idle", - frames = 4, - speed = 1/8 + frames = { + 1/8, + 1/8, + 1/8, + 1/8 + } } animation.nancy.run = { path = "assets/entities/nancy/run", - frames = 6, - speed = 1/8 + frames = { + 1/8, + 1/8, + 1/8, + 1/8, + 1/8, + 1/8 + } } animation.nancy.fall = { path = "assets/entities/nancy/fall", - frames = 3, - speed = 1/8 + frames = { + 1/8, + 1/8, + 1/8 + } } animation.nancy.jump = { path = "assets/entities/nancy/jump", - frames = 3, - speed = 1/8 + frames = { + 1/8, + 1/8, + 1/8 + } } -- animation initializer for _, object in pairs(animation) do for _, anim in pairs(object) do anim.imgs = {} - for i = 1, anim.frames do + for i = 1, #anim.frames do table.insert(anim.imgs,love.graphics.newImage(anim.path..tostring(i)..".png")) end end