feat: make ground level configurable

This commit is contained in:
Kazhnuz 2021-04-18 10:09:17 +02:00
parent dd841a4435
commit 45fc9005b5

View file

@ -17,9 +17,14 @@ Player:implement(Map)
local FRICTION = 480 * 3 local FRICTION = 480 * 3
local GRAV = 10 local GRAV = 10
local DEFAULT_GROUND_LEVEL = 0
local DEFAULT_GROUND_HEIGHT = 0
function Player:new(world, x, y, id) function Player:new(world, x, y, id)
Player.super.new(self, world, "player", x, y, 16, 16, true) 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.tweens = TweenManager(self)
self.onGround = true self.onGround = true
@ -66,9 +71,9 @@ function Player:applyGravity(dt)
end end
function Player:checkGround() function Player:checkGround()
if (self.z + self.zsp <= 0) then if (self.z + self.zsp <= self.groundLevel) then
self.onGround = true self.onGround = true
self.z = 0 self.z = self.groundLevel
self.zsp = 0 self.zsp = 0
self:endJump() self:endJump()
end end