feat: make ground level configurable
This commit is contained in:
parent
dd841a4435
commit
45fc9005b5
1 changed files with 7 additions and 2 deletions
|
@ -17,9 +17,14 @@ Player:implement(Map)
|
|||
|
||||
local FRICTION = 480 * 3
|
||||
local GRAV = 10
|
||||
local DEFAULT_GROUND_LEVEL = 0
|
||||
local DEFAULT_GROUND_HEIGHT = 0
|
||||
|
||||
function Player:new(world, x, y, id)
|
||||
Player.super.new(self, world, "player", x, y, 16, 16, true)
|
||||
self.groundLevel = DEFAULT_GROUND_LEVEL
|
||||
self.groundHeight = DEFAULT_GROUND_HEIGHT
|
||||
self.z = self.groundLevel
|
||||
self.tweens = TweenManager(self)
|
||||
|
||||
self.onGround = true
|
||||
|
@ -66,9 +71,9 @@ function Player:applyGravity(dt)
|
|||
end
|
||||
|
||||
function Player:checkGround()
|
||||
if (self.z + self.zsp <= 0) then
|
||||
if (self.z + self.zsp <= self.groundLevel) then
|
||||
self.onGround = true
|
||||
self.z = 0
|
||||
self.z = self.groundLevel
|
||||
self.zsp = 0
|
||||
self:endJump()
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue