Made instant DAS respect instant gravity.

This commit is contained in:
Joe Z 2019-07-07 17:25:35 -04:00 committed by Ishaan Bhardwaj
parent 8c1eaec1aa
commit 0393396d74
2 changed files with 11 additions and 8 deletions

View File

@ -78,12 +78,15 @@ function Piece:setRelativeRotation(rot)
return self return self
end end
function Piece:moveInGrid(step, squares, grid) function Piece:moveInGrid(step, squares, grid, instant)
local moved = false local moved = false
for x = 1, squares do for x = 1, squares do
if grid:canPlacePiece(self:withOffset(step)) then if grid:canPlacePiece(self:withOffset(step)) then
moved = true moved = true
self:setOffset(step) self:setOffset(step)
if instant then
self:dropToBottom(grid)
end
else else
break break
end end

View File

@ -128,16 +128,16 @@ function Ruleset:attemptWallkicks(piece, new_piece, rot_dir, grid)
-- do nothing in default ruleset -- do nothing in default ruleset
end end
function Ruleset:movePiece(piece, grid, move) function Ruleset:movePiece(piece, grid, move, instant)
local x = piece.position.x local x = piece.position.x
if move == "left" then if move == "left" then
piece:moveInGrid({x=-1, y=0}, 1, grid) piece:moveInGrid({x=-1, y=0}, 1, grid, false)
elseif move == "speedleft" then
piece:moveInGrid({x=-1, y=0}, 10, grid)
elseif move == "right" then elseif move == "right" then
piece:moveInGrid({x=1, y=0}, 1, grid) piece:moveInGrid({x=1, y=0}, 1, grid, false)
elseif move == "speedleft" then
piece:moveInGrid({x=-1, y=0}, 10, grid, instant)
elseif move == "speedright" then elseif move == "speedright" then
piece:moveInGrid({x=1, y=0}, 10, grid) piece:moveInGrid({x=1, y=0}, 10, grid, instant)
end end
if piece.position.x ~= x then if piece.position.x ~= x then
self:onPieceMove(piece, grid) self:onPieceMove(piece, grid)
@ -212,7 +212,7 @@ function Ruleset:processPiece(
hard_drop_enabled, additive_gravity hard_drop_enabled, additive_gravity
) )
self:rotatePiece(inputs, piece, grid, prev_inputs, false) self:rotatePiece(inputs, piece, grid, prev_inputs, false)
self:movePiece(piece, grid, move) self:movePiece(piece, grid, move, gravity >= 20)
self:dropPiece( self:dropPiece(
inputs, piece, grid, gravity, drop_speed, drop_locked, hard_drop_locked, inputs, piece, grid, gravity, drop_speed, drop_locked, hard_drop_locked,
hard_drop_enabled, additive_gravity hard_drop_enabled, additive_gravity