feat: get hitbox and z position from datas

This commit is contained in:
Kazhnuz 2022-05-20 19:11:23 +02:00
parent 4bb1635cce
commit 5368b94f88
4 changed files with 36 additions and 6 deletions

View file

@ -3,7 +3,9 @@ local PlayerMovement = Object:extend()
local SPEED = 160 local SPEED = 160
function PlayerMovement:initMovements() function PlayerMovement:initMovements()
self:setGravity(480 * 2) if (not self:isAerial()) then
self:setGravity(480 * 2)
end
end end
function PlayerMovement:updateMovements() function PlayerMovement:updateMovements()
@ -41,4 +43,12 @@ function PlayerMovement:isNotJumping()
return self.onGround return self.onGround
end end
function PlayerMovement:getStartZ()
if (self:isAerial()) then
return 16
else
return 0
end
end
return PlayerMovement return PlayerMovement

View file

@ -5,11 +5,18 @@ function FighterSprite:changeSprite(name)
self.assets:addSprite(name, self:getSpritePath(name)) self.assets:addSprite(name, self:getSpritePath(name))
end end
self.assets.sprites[name]:setCustomSpeed(16) 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:changeAnimation("idle")
self:setDirection(self.direction or self.defaultDir) self:setDirection(self.direction or self.defaultDir)
end end
function FighterSprite:getOrigin()
local _, _, d = self:getFighterHitbox()
return 8, (d - 14)
end
function FighterSprite:updateSprites(dt) function FighterSprite:updateSprites(dt)
self.sprite:setCustomSpeed(self:getCustomSpeed()) self.sprite:setCustomSpeed(self:getCustomSpeed())
self:setDirection(self.xsp) self:setDirection(self.xsp)

View file

@ -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

View file

@ -4,6 +4,7 @@ local Player = Parent:extend()
local Score = require "game.modules.subgames.world.actors.fighters.player.score" local Score = require "game.modules.subgames.world.actors.fighters.player.score"
local Sprites = require "game.modules.subgames.world.actors.fighters.player.sprites" local Sprites = require "game.modules.subgames.world.actors.fighters.player.sprites"
local Controls = require "game.modules.subgames.world.actors.fighters.player.controls" 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" local Team = require "scenes.overworld.actors.player.team"
@ -11,6 +12,7 @@ Player:implement(Score)
Player:implement(Sprites) Player:implement(Sprites)
Player:implement(Team) Player:implement(Team)
Player:implement(Controls) Player:implement(Controls)
Player:implement(Identity)
function Player:new(world, x, y, z, id) function Player:new(world, x, y, z, id)
self.defaultDir = 1 self.defaultDir = 1
@ -20,10 +22,6 @@ function Player:new(world, x, y, z, id)
self:initTeam() self:initTeam()
end end
function Player:getAbstract()
return game.characters.list[game.characters:getActiveCharacter()]
end
function Player:updateStart(dt) function Player:updateStart(dt)
self:applyInputs() self:applyInputs()
end end