WIP: new-cbs #117
5 changed files with 104 additions and 3 deletions
62
sonic-radiance.love/game/modules/subgames/hud.lua
Normal file
62
sonic-radiance.love/game/modules/subgames/hud.lua
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
local GuiScreen = require "birb.modules.gui.screen"
|
||||||
|
local OWScreen = GuiScreen:extend()
|
||||||
|
|
||||||
|
local Composite = require "birb.modules.gui.elements.composite"
|
||||||
|
local Counter = require "birb.modules.gui.elements.counter"
|
||||||
|
local Asset = require "birb.modules.gui.elements.assets"
|
||||||
|
|
||||||
|
local Emblems = require "scenes.overworld.gui.hudelements.emblems"
|
||||||
|
|
||||||
|
local show = {
|
||||||
|
-- {"rings", "movement", 0, 0.3, 16, 16, "inOutQuart"},
|
||||||
|
-- {"time", "movement", 0, 0.3, 408, 250, "inOutQuart"},
|
||||||
|
{"teamEmblems", "movement", 0, 0.3, 368, 24, "inOutQuart"},
|
||||||
|
-- {"lifebars", "movement", 0, 0.3, 8, 168, "inOutQuart"},
|
||||||
|
}
|
||||||
|
|
||||||
|
local hide = {
|
||||||
|
-- {"rings", "movement", 0, 0.3, -16, -16, "inOutQuart"},
|
||||||
|
-- {"time", "movement", 0, 0.3, 408, 250, "inOutQuart"},
|
||||||
|
{"teamEmblems", "movement", 0, 0.3, 500, 24, "inOutQuart"},
|
||||||
|
-- {"lifebars", "movement", 0, 0.3, -124, 168, "inOutQuart"},
|
||||||
|
}
|
||||||
|
|
||||||
|
local showMenu = {
|
||||||
|
-- {"rings", "movement", 0, 0.5, 8, 8, "inOutQuart"},
|
||||||
|
-- {"time", "movement", 0, 0.5, 408, 221, "inOutQuart"},
|
||||||
|
{"teamEmblems", "movement", 0, 0.3, 500, 24, "inOutQuart"},
|
||||||
|
-- {"lifebars", "movement", 0, 0.3, -124, 168, "inOutQuart"},
|
||||||
|
}
|
||||||
|
|
||||||
|
local hideMenu = {
|
||||||
|
-- {"rings", "movement", 0, 0.5, 16, 16, "inOutQuart"},
|
||||||
|
-- {"time", "movement", 0, 0.5, 408, 250, "inOutQuart"},
|
||||||
|
{"teamEmblems", "movement", 0, 0.3, 368, 24, "inOutQuart"},
|
||||||
|
-- {"lifebars", "movement", 0, 0.3, 8, 168, "inOutQuart"}
|
||||||
|
}
|
||||||
|
|
||||||
|
function OWScreen:new()
|
||||||
|
OWScreen.super.new(self, "hud")
|
||||||
|
self:addTransform("show", show)
|
||||||
|
self:addTransform("hide", hide)
|
||||||
|
self:addTransform("pause", showMenu)
|
||||||
|
self:addTransform("unpause", hideMenu)
|
||||||
|
self:show()
|
||||||
|
end
|
||||||
|
|
||||||
|
function OWScreen:createElements()
|
||||||
|
local list = {
|
||||||
|
-- {Composite("rings", -16, -16, {
|
||||||
|
-- {Asset("guiRing", "images", "guiRing", -1, -1), 0, 0},
|
||||||
|
-- {Counter("turnCnt", "hudnbrs", game.loot, "rings", 3, -1, -1), 14, 1}
|
||||||
|
-- }), 0, -100},
|
||||||
|
-- {TimeElement("hudnbrs", 408, 250, "right"), 0, -100},
|
||||||
|
Emblems(500, 24),
|
||||||
|
-- Lifebars(-124, 168),
|
||||||
|
-- Interactions()
|
||||||
|
}
|
||||||
|
|
||||||
|
return list
|
||||||
|
end
|
||||||
|
|
||||||
|
return OWScreen
|
|
@ -3,6 +3,7 @@ local PlayStyle = Scene:extend()
|
||||||
|
|
||||||
local TweenManager = require "birb.classes.time"
|
local TweenManager = require "birb.classes.time"
|
||||||
local PauseScreen = require("game.modules.subgames.pause")
|
local PauseScreen = require("game.modules.subgames.pause")
|
||||||
|
local HUD = require("game.modules.subgames.hud")
|
||||||
local TestWorld = require("game.modules.subgames.world.parent")
|
local TestWorld = require("game.modules.subgames.world.parent")
|
||||||
|
|
||||||
function PlayStyle:new(supportedLevels, missionfile)
|
function PlayStyle:new(supportedLevels, missionfile)
|
||||||
|
@ -17,6 +18,7 @@ function PlayStyle:new(supportedLevels, missionfile)
|
||||||
|
|
||||||
self.tweens = TweenManager(self)
|
self.tweens = TweenManager(self)
|
||||||
PauseScreen()
|
PauseScreen()
|
||||||
|
HUD()
|
||||||
|
|
||||||
self.haveStarted = false
|
self.haveStarted = false
|
||||||
self.canPause = true
|
self.canPause = true
|
||||||
|
|
|
@ -10,4 +10,13 @@ function PlayerActions:doActions()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function PlayerActions:actionSwitch()
|
||||||
|
if self.keys["L1"].isPressed and (self.action == "normal") and (self.onGround) then
|
||||||
|
self:switchActiveCharacter()
|
||||||
|
end
|
||||||
|
if self.keys["R1"].isPressed and (self.action == "normal") and (self.onGround) then
|
||||||
|
self:switchActiveCharacter(-1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return PlayerActions
|
return PlayerActions
|
|
@ -2,15 +2,19 @@ local cwd = (...):gsub('%.player$', '') .. "."
|
||||||
local Parent = require(cwd .. "parent")
|
local Parent = require(cwd .. "parent")
|
||||||
local Player = Parent:extend()
|
local Player = Parent:extend()
|
||||||
|
|
||||||
|
local TweenManager = require "birb.classes.time"
|
||||||
|
|
||||||
local Actions = require "game.modules.subgames.world.actors.player.actions"
|
local Actions = require "game.modules.subgames.world.actors.player.actions"
|
||||||
local Movements = require "game.modules.subgames.world.actors.player.movements"
|
local Movements = require "game.modules.subgames.world.actors.player.movements"
|
||||||
local Score = require "game.modules.subgames.world.actors.player.score"
|
local Score = require "game.modules.subgames.world.actors.player.score"
|
||||||
local Sprites = require "game.modules.subgames.world.actors.player.sprites"
|
local Sprites = require "game.modules.subgames.world.actors.player.sprites"
|
||||||
|
local Team = require "scenes.overworld.actors.player.team"
|
||||||
|
|
||||||
Player:implement(Actions)
|
Player:implement(Actions)
|
||||||
Player:implement(Movements)
|
Player:implement(Movements)
|
||||||
Player:implement(Score)
|
Player:implement(Score)
|
||||||
Player:implement(Sprites)
|
Player:implement(Sprites)
|
||||||
|
Player:implement(Team)
|
||||||
|
|
||||||
function Player:new(world, x, y, z, id)
|
function Player:new(world, x, y, z, id)
|
||||||
Player.super.new(self, world, "player", x, y, 0, 16, 12, 24, true)
|
Player.super.new(self, world, "player", x, y, 0, 16, 12, 24, true)
|
||||||
|
@ -18,19 +22,35 @@ function Player:new(world, x, y, z, id)
|
||||||
self:initCharactersSprites()
|
self:initCharactersSprites()
|
||||||
self:initScore()
|
self:initScore()
|
||||||
self:initActions()
|
self:initActions()
|
||||||
|
self:initTeam()
|
||||||
|
|
||||||
|
self.tweens = TweenManager(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Player:updateStart(dt)
|
function Player:updateStart(dt)
|
||||||
self:basicMovements()
|
self:basicMovements()
|
||||||
self:doActions()
|
self:doActions()
|
||||||
|
self:actionSwitch()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Player:update(dt)
|
||||||
|
Player.super.update(self, dt)
|
||||||
|
self.tweens:update(dt)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
function Player:collisionResponse(collision)
|
function Player:collisionResponse(collision)
|
||||||
if collision.other.type == "collectible" then
|
if collision.other.type == "collectible" then
|
||||||
collision.other.owner:getPicked(self)
|
collision.other.owner:getPicked(self)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Player:timerResponse(response)
|
||||||
|
if (response == "changeCharacter") then
|
||||||
|
self:endCharacterSwitchAnimation()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function Player:animationEnded(name)
|
function Player:animationEnded(name)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
local SpritedPlayer = Object:extend()
|
local SpritedPlayer = Object:extend()
|
||||||
|
|
||||||
function SpritedPlayer:initCharactersSprites()
|
function SpritedPlayer:initCharactersSprites()
|
||||||
self.charName = game.characters:getActiveCharacter()
|
for id, name in ipairs(game.characters.team) do
|
||||||
self.assets:addSprite(self.charName, "datas/gamedata/characters/" .. self.charName .. "/sprites")
|
self.assets:addSprite(name, "datas/gamedata/characters/" .. name .. "/sprites")
|
||||||
self:setSprite(self.charName, true, 8, 10)
|
end
|
||||||
|
self.direction = 1
|
||||||
|
self:updateCurrentCharset()
|
||||||
end
|
end
|
||||||
|
|
||||||
function SpritedPlayer:setAnimation()
|
function SpritedPlayer:setAnimation()
|
||||||
|
@ -38,4 +40,10 @@ function SpritedPlayer:setDirection(direction)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function SpritedPlayer:updateCurrentCharset()
|
||||||
|
self.charName = game.characters:getActiveCharacter()
|
||||||
|
self:setSprite(self.charName, true, 8, 10)
|
||||||
|
self.sprite:setScallingX(self.direction)
|
||||||
|
end
|
||||||
|
|
||||||
return SpritedPlayer
|
return SpritedPlayer
|
||||||
|
|
Loading…
Reference in a new issue