feat: get hitbox and z position from datas
This commit is contained in:
parent
4bb1635cce
commit
5368b94f88
4 changed files with 36 additions and 6 deletions
|
@ -3,7 +3,9 @@ local PlayerMovement = Object:extend()
|
|||
local SPEED = 160
|
||||
|
||||
function PlayerMovement:initMovements()
|
||||
self:setGravity(480 * 2)
|
||||
if (not self:isAerial()) then
|
||||
self:setGravity(480 * 2)
|
||||
end
|
||||
end
|
||||
|
||||
function PlayerMovement:updateMovements()
|
||||
|
@ -41,4 +43,12 @@ function PlayerMovement:isNotJumping()
|
|||
return self.onGround
|
||||
end
|
||||
|
||||
function PlayerMovement:getStartZ()
|
||||
if (self:isAerial()) then
|
||||
return 16
|
||||
else
|
||||
return 0
|
||||
end
|
||||
end
|
||||
|
||||
return PlayerMovement
|
||||
|
|
|
@ -5,11 +5,18 @@ function FighterSprite:changeSprite(name)
|
|||
self.assets:addSprite(name, self:getSpritePath(name))
|
||||
end
|
||||
self.assets.sprites[name]:setCustomSpeed(16)
|
||||
self:setSprite(name, true, 8, 10)
|
||||
local ox, oy = self:getOrigin()
|
||||
self:setSprite(name, true, ox, oy)
|
||||
self:changeAnimation("idle")
|
||||
self:setDirection(self.direction or self.defaultDir)
|
||||
end
|
||||
|
||||
function FighterSprite:getOrigin()
|
||||
local _, _, d = self:getFighterHitbox()
|
||||
|
||||
return 8, (d - 14)
|
||||
end
|
||||
|
||||
function FighterSprite:updateSprites(dt)
|
||||
self.sprite:setCustomSpeed(self:getCustomSpeed())
|
||||
self:setDirection(self.xsp)
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
local PlayerHitboxes = Object:extend()
|
||||
|
||||
function PlayerHitboxes:getAbstract()
|
||||
return game.characters.list[game.characters:getActiveCharacter()]
|
||||
end
|
||||
|
||||
function PlayerHitboxes:getFighterHitbox()
|
||||
return 16, 12, 24
|
||||
end
|
||||
|
||||
function PlayerHitboxes:isAerial()
|
||||
return false
|
||||
end
|
||||
|
||||
return PlayerHitboxes
|
|
@ -4,6 +4,7 @@ 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 Identity = require "game.modules.subgames.world.actors.fighters.player.identity"
|
||||
|
||||
local Team = require "scenes.overworld.actors.player.team"
|
||||
|
||||
|
@ -11,6 +12,7 @@ Player:implement(Score)
|
|||
Player:implement(Sprites)
|
||||
Player:implement(Team)
|
||||
Player:implement(Controls)
|
||||
Player:implement(Identity)
|
||||
|
||||
function Player:new(world, x, y, z, id)
|
||||
self.defaultDir = 1
|
||||
|
@ -20,10 +22,6 @@ function Player:new(world, x, y, z, id)
|
|||
self:initTeam()
|
||||
end
|
||||
|
||||
function Player:getAbstract()
|
||||
return game.characters.list[game.characters:getActiveCharacter()]
|
||||
end
|
||||
|
||||
function Player:updateStart(dt)
|
||||
self:applyInputs()
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue