From 45fc9005b5c527899b63e9e828555c7958bb7c54 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 18 Apr 2021 10:09:17 +0200 Subject: [PATCH] feat: make ground level configurable --- .../scenes/overworld/actors/player/init.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sonic-radiance.love/scenes/overworld/actors/player/init.lua b/sonic-radiance.love/scenes/overworld/actors/player/init.lua index 75974c8..0ece93b 100644 --- a/sonic-radiance.love/scenes/overworld/actors/player/init.lua +++ b/sonic-radiance.love/scenes/overworld/actors/player/init.lua @@ -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