From 4d22e35288a8aa9d41d9dad9499bd69cc4442034 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Thu, 19 May 2022 12:45:20 +0200 Subject: [PATCH] improvement: add a fighter parent --- .../subgames/world/actors/fighters/init.lua | 73 ------------------- .../actors/fighters/{ => mixins}/actions.lua | 0 .../fighters/{ => mixins}/movements.lua | 0 .../subgames/world/actors/fighters/parent.lua | 34 +++++++++ .../actors/fighters/{ => player}/controls.lua | 0 .../world/actors/fighters/player/init.lua | 51 +++++++++++++ .../actors/fighters/{ => player}/score.lua | 0 .../actors/fighters/{ => player}/sprites.lua | 0 .../modules/subgames/world/actors/init.lua | 2 +- 9 files changed, 86 insertions(+), 74 deletions(-) delete mode 100644 sonic-radiance.love/game/modules/subgames/world/actors/fighters/init.lua rename sonic-radiance.love/game/modules/subgames/world/actors/fighters/{ => mixins}/actions.lua (100%) rename sonic-radiance.love/game/modules/subgames/world/actors/fighters/{ => mixins}/movements.lua (100%) create mode 100644 sonic-radiance.love/game/modules/subgames/world/actors/fighters/parent.lua rename sonic-radiance.love/game/modules/subgames/world/actors/fighters/{ => player}/controls.lua (100%) create mode 100644 sonic-radiance.love/game/modules/subgames/world/actors/fighters/player/init.lua rename sonic-radiance.love/game/modules/subgames/world/actors/fighters/{ => player}/score.lua (100%) rename sonic-radiance.love/game/modules/subgames/world/actors/fighters/{ => player}/sprites.lua (100%) diff --git a/sonic-radiance.love/game/modules/subgames/world/actors/fighters/init.lua b/sonic-radiance.love/game/modules/subgames/world/actors/fighters/init.lua deleted file mode 100644 index 9552408..0000000 --- a/sonic-radiance.love/game/modules/subgames/world/actors/fighters/init.lua +++ /dev/null @@ -1,73 +0,0 @@ -local cwd = (...):gsub('%.player$', '') .. "." -local Parent = require(cwd .. "parent") -local Player = Parent:extend() - -local TweenManager = require "birb.classes.time" - -local Actions = require "game.modules.subgames.world.actors.player.actions" -local Movements = require "game.modules.subgames.world.actors.player.movements" -local Score = require "game.modules.subgames.world.actors.player.score" -local Sprites = require "game.modules.subgames.world.actors.player.sprites" -local Controls = require "game.modules.subgames.world.actors.player.controls" - -local Team = require "scenes.overworld.actors.player.team" - -Player:implement(Actions) -Player:implement(Movements) -Player:implement(Score) -Player:implement(Sprites) -Player:implement(Team) -Player:implement(Controls) - -function Player:new(world, x, y, z, id) - Player.super.new(self, world, "player", x, y, 0, 16, 12, 24, true) - self:initMovements() - self:initCharactersSprites() - self:initScore() - self:initActions() - self:initTeam() - - self.tweens = TweenManager(self) -end - -function Player:updateStart(dt) - self:applyInputs() -end - -function Player:update(dt) - self:updateMovements(dt) - Player.super.update(self, dt) - self.tweens:update(dt) -end - - -function Player:collisionResponse(collision) - if collision.other.type == "collectible" then - collision.other.owner:getPicked(self) - end -end - -function Player:timerResponse(response) - if (response == "changeCharacter") then - self:endCharacterSwitchAnimation() - end -end - -function Player:animationEnded(name) - -end - -function Player:updateEnd(dt) - self:setAnimation() -end - -function Player:getViewCenter() - local x, y = Player.super.getViewCenter(self) - return x, y-16 -end - -function Player:draw() - Player.super.draw(self) -end - -return Player diff --git a/sonic-radiance.love/game/modules/subgames/world/actors/fighters/actions.lua b/sonic-radiance.love/game/modules/subgames/world/actors/fighters/mixins/actions.lua similarity index 100% rename from sonic-radiance.love/game/modules/subgames/world/actors/fighters/actions.lua rename to sonic-radiance.love/game/modules/subgames/world/actors/fighters/mixins/actions.lua diff --git a/sonic-radiance.love/game/modules/subgames/world/actors/fighters/movements.lua b/sonic-radiance.love/game/modules/subgames/world/actors/fighters/mixins/movements.lua similarity index 100% rename from sonic-radiance.love/game/modules/subgames/world/actors/fighters/movements.lua rename to sonic-radiance.love/game/modules/subgames/world/actors/fighters/mixins/movements.lua diff --git a/sonic-radiance.love/game/modules/subgames/world/actors/fighters/parent.lua b/sonic-radiance.love/game/modules/subgames/world/actors/fighters/parent.lua new file mode 100644 index 0000000..4c8facf --- /dev/null +++ b/sonic-radiance.love/game/modules/subgames/world/actors/fighters/parent.lua @@ -0,0 +1,34 @@ +local Parent = require("game.modules.subgames.world.actors.parent") +local FighterParent = Parent:extend() + +local TweenManager = require "birb.classes.time" + +local Actions = require "game.modules.subgames.world.actors.fighters.mixins.actions" +local Movements = require "game.modules.subgames.world.actors.fighters.mixins.movements" + +FighterParent:implement(Actions) +FighterParent:implement(Movements) +FighterParent:implement(Score) +FighterParent:implement(Sprites) +FighterParent:implement(Team) +FighterParent:implement(Controls) + +function FighterParent:new(world, x, y, w, h, d, fighterType) + FighterParent.super.new(self, world, fighterType, x, y, 0, w, h, d, true) + self:initMovements() + self:initActions() + + self.tweens = TweenManager(self) +end + +function FighterParent:update(dt) + self:updateMovements(dt) + FighterParent.super.update(self, dt) + self.tweens:update(dt) +end + +function FighterParent:animationEnded(name) + +end + +return FighterParent diff --git a/sonic-radiance.love/game/modules/subgames/world/actors/fighters/controls.lua b/sonic-radiance.love/game/modules/subgames/world/actors/fighters/player/controls.lua similarity index 100% rename from sonic-radiance.love/game/modules/subgames/world/actors/fighters/controls.lua rename to sonic-radiance.love/game/modules/subgames/world/actors/fighters/player/controls.lua diff --git a/sonic-radiance.love/game/modules/subgames/world/actors/fighters/player/init.lua b/sonic-radiance.love/game/modules/subgames/world/actors/fighters/player/init.lua new file mode 100644 index 0000000..2b805ab --- /dev/null +++ b/sonic-radiance.love/game/modules/subgames/world/actors/fighters/player/init.lua @@ -0,0 +1,51 @@ +local Parent = require("game.modules.subgames.world.actors.fighters.parent") +local Player = Parent:extend() + +local Score = require "game.modules.subgames.world.actors.fighters.player.score" +local Sprites = require "game.modules.subgames.world.actors.fighters.player.sprites" +local Controls = require "game.modules.subgames.world.actors.fighters.player.controls" + +local Team = require "scenes.overworld.actors.player.team" + +Player:implement(Score) +Player:implement(Sprites) +Player:implement(Team) +Player:implement(Controls) + +function Player:new(world, x, y, z, id) + Player.super.new(self, world, x, y, 16, 12, 24, "fighter") + self:initCharactersSprites() + self:initScore() + self:initTeam() +end + +function Player:updateStart(dt) + self:applyInputs() +end + +function Player:collisionResponse(collision) + if collision.other.type == "collectible" then + collision.other.owner:getPicked(self) + end +end + +function Player:timerResponse(response) + if (response == "changeCharacter") then + self:endCharacterSwitchAnimation() + end +end + +function Player:animationEnded(name) + +end + +function Player:updateEnd(dt) + self:setAnimation() +end + +function Player:getViewCenter() + local x, y = Player.super.getViewCenter(self) + return x, y-16 +end + +return Player diff --git a/sonic-radiance.love/game/modules/subgames/world/actors/fighters/score.lua b/sonic-radiance.love/game/modules/subgames/world/actors/fighters/player/score.lua similarity index 100% rename from sonic-radiance.love/game/modules/subgames/world/actors/fighters/score.lua rename to sonic-radiance.love/game/modules/subgames/world/actors/fighters/player/score.lua diff --git a/sonic-radiance.love/game/modules/subgames/world/actors/fighters/sprites.lua b/sonic-radiance.love/game/modules/subgames/world/actors/fighters/player/sprites.lua similarity index 100% rename from sonic-radiance.love/game/modules/subgames/world/actors/fighters/sprites.lua rename to sonic-radiance.love/game/modules/subgames/world/actors/fighters/player/sprites.lua diff --git a/sonic-radiance.love/game/modules/subgames/world/actors/init.lua b/sonic-radiance.love/game/modules/subgames/world/actors/init.lua index fea28f9..484af22 100644 --- a/sonic-radiance.love/game/modules/subgames/world/actors/init.lua +++ b/sonic-radiance.love/game/modules/subgames/world/actors/init.lua @@ -2,7 +2,7 @@ local Obj = {} -- On charge toutes les différentes types d'acteurs local cwd = (...):gsub('%.init$', '') .. "." -Obj.Player = require(cwd .. "player") +Obj.Player = require(cwd .. "fighters.player") Obj.Ring = require(cwd .. "items.ring") Obj.index = {}