diff --git a/examples/gameplay/moveplayer3D/actors/parent.lua b/examples/gameplay/moveplayer3D/actors/parent.lua index 2a43c98..b71c7e0 100644 --- a/examples/gameplay/moveplayer3D/actors/parent.lua +++ b/examples/gameplay/moveplayer3D/actors/parent.lua @@ -7,6 +7,7 @@ function Parent:new(world, type, x, y, z, w, h, d, isSolid) end function Parent:draw() + Parent.super.draw(self) self:drawMainHitbox() end diff --git a/examples/gameplay/moveplayer3D/actors/player.lua b/examples/gameplay/moveplayer3D/actors/player.lua index ea3875a..6825838 100644 --- a/examples/gameplay/moveplayer3D/actors/player.lua +++ b/examples/gameplay/moveplayer3D/actors/player.lua @@ -5,6 +5,9 @@ local Player = Parent:extend() function Player:new(world, x, y, z, id) Player.super.new(self, world, "player", x, y, 0, 16, 16, 24, true) self:setGravity(480) + + self:setSprite("player", 8, 12) + self:cloneSprite() end function Player:updateStart(dt) @@ -23,11 +26,33 @@ function Player:updateStart(dt) self.xsp = 120 end - if self.keys["A"].isDown then + if self.keys["A"].isDown and (self.onGround) then self.zsp = 280 end end +function Player:updateEnd(dt) + self:setAnimation() +end + +function Player:setAnimation() + self:setCustomSpeed(math.abs(self.xsp) / 12) + if (self.isPunching) then + self:changeAnimation("punch", false) + else + if (self.onGround) then + if (math.abs(self.xsp) > 0) or (math.abs(self.ysp) > 0) then + self:changeAnimation("walk", false) + else + self:changeAnimation("idle", true) + end + else + self:changeAnimation("jump", true) + end + end +end + + function Player:draw() Player.super.draw(self) end diff --git a/examples/gameplay/moveplayer3D/init.lua b/examples/gameplay/moveplayer3D/init.lua index 7475f1d..55f9789 100644 --- a/examples/gameplay/moveplayer3D/init.lua +++ b/examples/gameplay/moveplayer3D/init.lua @@ -28,9 +28,9 @@ local World = require "gamecore.modules.world.world3D" function MovePlayer:new() MovePlayer.super.new(self) + self.assets:batchImport("examples.gameplay.plateform.assets") World(self, "examples.gameplay.moveplayer3D.actors", "examples/gameplay/moveplayer3D/assets/arena.lua") - self.world:setPlayerNumber(1) self.world:loadMap()