feat: add a way to load / unload the battlesystem
This commit is contained in:
parent
ab3e4eadd8
commit
f0b696117b
9 changed files with 102 additions and 0 deletions
BIN
sonic-radiance.love/assets/transitions/border.png
Normal file
BIN
sonic-radiance.love/assets/transitions/border.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.3 KiB |
BIN
sonic-radiance.love/assets/transitions/eggdecal.png
Normal file
BIN
sonic-radiance.love/assets/transitions/eggdecal.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
BIN
sonic-radiance.love/assets/transitions/sonicdecal.png
Normal file
BIN
sonic-radiance.love/assets/transitions/sonicdecal.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
38
sonic-radiance.love/game/battle.lua
Normal file
38
sonic-radiance.love/game/battle.lua
Normal file
|
@ -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
|
|
@ -28,6 +28,7 @@ local Characters = require "game.characters"
|
||||||
local Ennemies = require "game.ennemies"
|
local Ennemies = require "game.ennemies"
|
||||||
local Skills = require "game.skills"
|
local Skills = require "game.skills"
|
||||||
local Loot = require "game.loot"
|
local Loot = require "game.loot"
|
||||||
|
local CBSCore = require "game.battle"
|
||||||
|
|
||||||
local binser = require "core.modules.gamesystem.libs.binser"
|
local binser = require "core.modules.gamesystem.libs.binser"
|
||||||
|
|
||||||
|
@ -43,6 +44,7 @@ function Game:new()
|
||||||
self.ennemies = Ennemies(self)
|
self.ennemies = Ennemies(self)
|
||||||
self.skills = Skills(self)
|
self.skills = Skills(self)
|
||||||
self.loot = Loot(self)
|
self.loot = Loot(self)
|
||||||
|
self.cbs = CBSCore(self)
|
||||||
|
|
||||||
self.flags = {}
|
self.flags = {}
|
||||||
self.destroyedGizmo = {}
|
self.destroyedGizmo = {}
|
||||||
|
|
8
sonic-radiance.love/game/modules/transitions/eggman.lua
Normal file
8
sonic-radiance.love/game/modules/transitions/eggman.lua
Normal file
|
@ -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
|
5
sonic-radiance.love/game/modules/transitions/init.lua
Normal file
5
sonic-radiance.love/game/modules/transitions/init.lua
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
return {
|
||||||
|
sonic = require "game.modules.transitions.sonic",
|
||||||
|
eggman = require "game.modules.transitions.eggman",
|
||||||
|
borders = require "game.modules.transitions.zigzag",
|
||||||
|
}
|
8
sonic-radiance.love/game/modules/transitions/sonic.lua
Normal file
8
sonic-radiance.love/game/modules/transitions/sonic.lua
Normal file
|
@ -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
|
41
sonic-radiance.love/game/modules/transitions/zigzag.lua
Normal file
41
sonic-radiance.love/game/modules/transitions/zigzag.lua
Normal file
|
@ -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
|
Loading…
Reference in a new issue