Fixed a clipping issue with negative gravity

Gamemodes are able to define their own piece class behavior to override negative gravity handling
This commit is contained in:
Ishaan Bhardwaj 2021-02-21 10:05:09 -05:00
parent 3cf5daeb2e
commit eae58f11e9

View File

@ -126,7 +126,9 @@ function Piece:addGravity(gravity, grid, classic_lock)
self.gravity = 0
self.lock_delay = self.lock_delay + 1
end
else
elseif not (
self:isMoveBlocked(grid, { x=0, y=-1 }) and gravity < 0
) then
local dropped_squares = math.floor(math.abs(new_gravity))
local new_frac_gravity = new_gravity - dropped_squares
self.gravity = new_frac_gravity
@ -142,6 +144,8 @@ function Piece:addGravity(gravity, grid, classic_lock)
self.gravity = new_frac_gravity
self:moveInGrid({ x = 0, y = -1 }, dropped_squares, grid)
end
else
self.gravity = 0
end
return self
end