screen borders
This commit is contained in:
parent
85225f7c2d
commit
a71461dac0
@ -9,7 +9,8 @@ function Player:init(x, y, gameManager)
|
|||||||
local playerImageTable = gfx.imagetable.new("sprites/player-table-48-48")
|
local playerImageTable = gfx.imagetable.new("sprites/player-table-48-48")
|
||||||
Player.super.init(self, playerImageTable)
|
Player.super.init(self, playerImageTable)
|
||||||
|
|
||||||
self:addState("run", 8,14, {tickStep = 2})
|
-- self:addState("run", 8,14, {tickStep = 2})
|
||||||
|
self:addState("run", 1,7, {tickStep = 2})
|
||||||
self:addState("up", 1,7, {tickStep = 6})
|
self:addState("up", 1,7, {tickStep = 6})
|
||||||
self:addState("down", 1,7, {tickStep = 6})
|
self:addState("down", 1,7, {tickStep = 6})
|
||||||
self:addState("boom", 15,21, {tickStep = 10, loop = false})
|
self:addState("boom", 15,21, {tickStep = 10, loop = false})
|
||||||
@ -63,10 +64,12 @@ function Player:handleGroundInput(state)
|
|||||||
|
|
||||||
if pd.buttonIsPressed(pd.kButtonLeft) then
|
if pd.buttonIsPressed(pd.kButtonLeft) then
|
||||||
self:changeToRunState("left")
|
self:changeToRunState("left")
|
||||||
|
self:setRotation(10)
|
||||||
self.cantDown = true
|
self.cantDown = true
|
||||||
Player.moveRight = false
|
Player.moveRight = false
|
||||||
elseif pd.buttonIsPressed(pd.kButtonRight) then
|
elseif pd.buttonIsPressed(pd.kButtonRight) then
|
||||||
self:changeToRunState("right")
|
self:changeToRunState("right")
|
||||||
|
self:setRotation(10)
|
||||||
self.cantDown = true
|
self.cantDown = true
|
||||||
Player.moveRight = true
|
Player.moveRight = true
|
||||||
end
|
end
|
||||||
@ -93,6 +96,7 @@ function Player:changeToDownState()
|
|||||||
self.yVelocity = self.fallSpeed
|
self.yVelocity = self.fallSpeed
|
||||||
self.xVelocity = 0
|
self.xVelocity = 0
|
||||||
self:changeState("down")
|
self:changeState("down")
|
||||||
|
self:setRotation(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Player:changeToRunState(direction)
|
function Player:changeToRunState(direction)
|
||||||
@ -108,7 +112,17 @@ function Player:changeToRunState(direction)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Player:handleMovementAndCollisions()
|
function Player:handleMovementAndCollisions()
|
||||||
local _, _, collisions, length = self:moveWithCollisions(self.x + self.xVelocity, self.y + self.yVelocity)
|
local _
|
||||||
|
local collisions
|
||||||
|
local length = 0
|
||||||
|
|
||||||
|
if self.x >= 20 and self.x <= 380 then
|
||||||
|
_, _, collisions, length = self:moveWithCollisions(self.x + self.xVelocity, self.y + self.yVelocity)
|
||||||
|
elseif self.x == 380 then
|
||||||
|
self.x = 380
|
||||||
|
else
|
||||||
|
self.x = 20
|
||||||
|
end
|
||||||
|
|
||||||
self.touchingGround = false
|
self.touchingGround = false
|
||||||
self.touchingCeiling = false
|
self.touchingCeiling = false
|
||||||
|
Loading…
Reference in New Issue
Block a user