From f0b696117b797b96d059400636266f16a08cb040 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Fri, 2 Apr 2021 22:23:39 +0200 Subject: [PATCH] feat: add a way to load / unload the battlesystem --- .../assets/transitions/border.png | Bin 0 -> 6443 bytes .../assets/transitions/eggdecal.png | Bin 0 -> 1222 bytes .../assets/transitions/sonicdecal.png | Bin 0 -> 2535 bytes sonic-radiance.love/game/battle.lua | 38 ++++++++++++++++ sonic-radiance.love/game/init.lua | 2 + .../game/modules/transitions/eggman.lua | 8 ++++ .../game/modules/transitions/init.lua | 5 +++ .../game/modules/transitions/sonic.lua | 8 ++++ .../game/modules/transitions/zigzag.lua | 41 ++++++++++++++++++ 9 files changed, 102 insertions(+) create mode 100644 sonic-radiance.love/assets/transitions/border.png create mode 100644 sonic-radiance.love/assets/transitions/eggdecal.png create mode 100644 sonic-radiance.love/assets/transitions/sonicdecal.png create mode 100644 sonic-radiance.love/game/battle.lua create mode 100644 sonic-radiance.love/game/modules/transitions/eggman.lua create mode 100644 sonic-radiance.love/game/modules/transitions/init.lua create mode 100644 sonic-radiance.love/game/modules/transitions/sonic.lua create mode 100644 sonic-radiance.love/game/modules/transitions/zigzag.lua diff --git a/sonic-radiance.love/assets/transitions/border.png b/sonic-radiance.love/assets/transitions/border.png new file mode 100644 index 0000000000000000000000000000000000000000..93cc110022b5bb30ca4f9ad6f044f5a7bd79a613 GIT binary patch literal 6443 zcmeHLc|25WA0Ki{sL0x)j!`7dKFrb#F{Vt6y)042%$YG|7BgqekWfmL(oU;##ZCKS zt0ZaDDxp-miL12la)tNIQ0aYpyRZ9s?|=Dxe4g_>=llCUzvp|t&+j>B(tNyT4AUE} zhd>~PvE1GK;C3ehp@q;L3||p*7by`4oqKTsL69Fu2}orUzAy>|pjasgfGQy$fl%Ff z9vD{BJjo#bk;y_G4_DpQmDvR!1~2?1N?nhsQng;LebJnCBpTtd>bTK_D~a77UYVoK zR#_GN5#UFao*Stjc(SEArmid3`o$yvo84VCYW8M=wW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kig&>77jHEbdY1r+@L|1TJmIo9?q%5kQb1s zm?hjLChSsF!*fLD9ELe5ee*C&1Xe{SzYUy|sG7C9aW1 zYEDAUKVR_+oYqQVP_m3X00009a7bBm001r{001r{0eGc9b^rhX2XskIMF-^s0ul%p zfqXU#0000SbVXQnLvL+uWo~o;Lvm$dbY)~9cWHEJAV+LzZE$mC?oJp70009WNkl zvuZsB&axQ?KuD)O(E(T7Wj?J}2V7?Y88HK%1BsDSv1;SNiLY}%=Q!JC}mh<3USr&WLOe9>XPLA)xg6$ik3A&V@e&hAiklJYn2un)?t(;i0|(j6<6Q{Id4us`^Ej_)bg z*>rkNKQEfXxDH%Iczv|cS~r%FlskiI=H9E;vVNJ0Yg@*4(^7BU#FW_mSmn9Ddo^y+ zrxvuw8E$}^aMZ&&m+LZhCEfe%DxjFwww^~oCF*C!=nN35Wgu9N*ql~Bce5_Fy=%-) z?PP2x8ZFoe7DW?RAWOYE4>@jT<^a8QLo?0#ALck`;KpAX1~et_*N87%$`R1yyovMs zkG}@w#Q literal 0 HcmV?d00001 diff --git a/sonic-radiance.love/assets/transitions/sonicdecal.png b/sonic-radiance.love/assets/transitions/sonicdecal.png new file mode 100644 index 0000000000000000000000000000000000000000..f5f30397461d4040379d9386861fb30c02a7ab29 GIT binary patch literal 2535 zcmVEX>4Tx02q~xkikj=F%(5_q*xaUBH}_^bm78H!G(5TEDTD8aa6GGGRX*HGKQHc z(p^8nkMT3Q6Z!{!K|x%4la{Uw7M&$X$GT2W_=C*`UJ5NG7xTjM+%^8U+Rc0rz!ceO1w z`JH^Mt@ivu9#}J0D^Gu$?V`NDrCu?Pkig&>77jHEbdY1r+@L|1TJmIo9?q%5kQb1s zm?hjLChSsF!*fLD9ELe5ee*C&1Xe{SzYUy|sG7C9aW1 zYEDAUKVR_+oYqQVP_m3X00009a7bBm001r{001r{0eGc9b^rhX2XskIMF-^s0ul)- zzz<7X0000SbVXQnLvL+uWo~o;Lvm$dbY)~9cWHEJAV+LzZE$mC?o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sgaBe$MDXBV-gK)hp7}P16nO!_Ks_R+#SlAg1+g-#eRe

L2?UvH%0MM}%@$x8Vx|G#waMo&$Ytf{q=Vd)DC@6nzwhV6= ztdJ{1Bb;PBV0LPLX3@Qer2qiE{;~`Wp6P?2xTttI@HUl#=j^F|Wz|Q{@-Msz;&7Uj zL*EVbX|>Z_VakyM$kQ>GE)}JT!-s0l+CiMpI*)B+o#)l&R#1OVk@ETsIo9SgmOA$Z|jPBV>o#Q185bw1C0Q}3-K;>w82*T zx;CC}Pk-2Ts>t>P0GLvRmjh`@yIIv#oftt|1$eF@-dpfuc>sWXAL4-q)TjB%ajQX9EkW(K3|mnSnfLsaO<5NJjW!dZ?pB1%&PBWv!E%nGT7R;l3GlF} zJEWbUXf{*sS(r&5UmL`CWi|6T5or=*i;Omu->Cxr=D)n0gthdy!7R=CO-;gyP=DzY zxQwi2)jR0_>SjA4ro@17<})>wP@AOnR)1jn7!cUHttN6^>qt_4%*U`GspojmL{R_;klozmQUYGy?002ovPDHLkV1oNjweJ7` literal 0 HcmV?d00001 diff --git a/sonic-radiance.love/game/battle.lua b/sonic-radiance.love/game/battle.lua new file mode 100644 index 0000000..4df6dbf --- /dev/null +++ b/sonic-radiance.love/game/battle.lua @@ -0,0 +1,38 @@ +local CoreCBS = Object:extend() + +local battleutils = require "game.utils.battle" +local defTransitions = require "core.modules.transitions" +local radTransitions = require "game.modules.transitions" + +local DEFAULTX = 424/2 +local DEFAULTY = 240/2 + +function CoreCBS:new() + self.lastx, self.lasty = DEFAULTX, DEFAULTY +end + +function CoreCBS:startBattle(category, name, x, y) + local data = battleutils.getBattleData(category, name) + self.lastx, self.lasty = x or DEFAULTX, y or DEFAULTY + core.screen:startTransition(radTransitions.eggman, radTransitions.borders, function() scenes.cbs(data) end, x, y) +end + +function CoreCBS:endBattle(isFleeing) + local transitionEnd = radTransitions.sonic + if (isFleeing) then + transitionEnd = defTransitions.circle; + end + core.screen:startTransition(radTransitions.borders, transitionEnd, + function() + if (core.scenemanager:haveStoredScene("afterBattle")) then + core.scenemanager:setStoredScene("afterBattle") + else + scenes.debug.menu() + end + end, self.lastx, self.lasty) + self.lastx, self.lasty = DEFAULTX, DEFAULTY +end + + + +return CoreCBS \ No newline at end of file diff --git a/sonic-radiance.love/game/init.lua b/sonic-radiance.love/game/init.lua index c6b28e6..66599d1 100644 --- a/sonic-radiance.love/game/init.lua +++ b/sonic-radiance.love/game/init.lua @@ -28,6 +28,7 @@ local Characters = require "game.characters" local Ennemies = require "game.ennemies" local Skills = require "game.skills" local Loot = require "game.loot" +local CBSCore = require "game.battle" local binser = require "core.modules.gamesystem.libs.binser" @@ -43,6 +44,7 @@ function Game:new() self.ennemies = Ennemies(self) self.skills = Skills(self) self.loot = Loot(self) + self.cbs = CBSCore(self) self.flags = {} self.destroyedGizmo = {} diff --git a/sonic-radiance.love/game/modules/transitions/eggman.lua b/sonic-radiance.love/game/modules/transitions/eggman.lua new file mode 100644 index 0000000..2081a44 --- /dev/null +++ b/sonic-radiance.love/game/modules/transitions/eggman.lua @@ -0,0 +1,8 @@ +local DecalTransition = require "core.modules.transitions.decal" +local EggmanTransition = DecalTransition:extend() + +function EggmanTransition:new(func, ox, oy, fadeOut) + EggmanTransition.super.new(self, func, ox, oy, fadeOut, "eggdecal") +end + +return EggmanTransition \ No newline at end of file diff --git a/sonic-radiance.love/game/modules/transitions/init.lua b/sonic-radiance.love/game/modules/transitions/init.lua new file mode 100644 index 0000000..6aa01a5 --- /dev/null +++ b/sonic-radiance.love/game/modules/transitions/init.lua @@ -0,0 +1,5 @@ +return { + sonic = require "game.modules.transitions.sonic", + eggman = require "game.modules.transitions.eggman", + borders = require "game.modules.transitions.zigzag", +} \ No newline at end of file diff --git a/sonic-radiance.love/game/modules/transitions/sonic.lua b/sonic-radiance.love/game/modules/transitions/sonic.lua new file mode 100644 index 0000000..c636128 --- /dev/null +++ b/sonic-radiance.love/game/modules/transitions/sonic.lua @@ -0,0 +1,8 @@ +local DecalTransition = require "core.modules.transitions.decal" +local SonicTransition = DecalTransition:extend() + +function SonicTransition:new(func, ox, oy, fadeOut) + SonicTransition.super.new(self, func, ox, oy, fadeOut, "sonicdecal") +end + +return SonicTransition \ No newline at end of file diff --git a/sonic-radiance.love/game/modules/transitions/zigzag.lua b/sonic-radiance.love/game/modules/transitions/zigzag.lua new file mode 100644 index 0000000..3334c24 --- /dev/null +++ b/sonic-radiance.love/game/modules/transitions/zigzag.lua @@ -0,0 +1,41 @@ +local CanvasTransition = require "core.modules.transitions.canvas" +local ZigZagTransition = CanvasTransition:extend() + +function ZigZagTransition:new(func, ox, oy, fadeOut) + self.offset = 0 + ZigZagTransition.super.new(self, func, ox, oy, fadeOut, "inQuad", "outQuad", 1, 0.1) + +end + +function ZigZagTransition:loadResources() + self.border = love.graphics.newImage("assets/transitions/border.png") +end + +function ZigZagTransition:drawCanvas(dt) + local w, _ = self.border:getDimensions() + self.offset = (self.offset + (dt * 256)) % w + utils.graphics.resetColor() + love.graphics.rectangle("fill", 0, 0, 424, 240) + love.graphics.setColor(0,0,0,1) + local max = 120 + 16 + self:drawBorder(0 + max * (self.value), false) + utils.graphics.resetColor() + self:drawBorder(240 - max * (self.value), true) +end + +function ZigZagTransition:drawBorder(y, reversed) + local offset = self.offset + local sy = 1 + if (reversed) then + offset = self.offset * -1 + sy = -1 + end + local w, h = self.border:getDimensions() + local ox, oy = 0, h + for i = -1, math.ceil(424 / w), 1 do + love.graphics.draw(self.border,(i * w) + offset,y,0,1,sy,ox,oy) + end + +end + +return ZigZagTransition \ No newline at end of file