mirror of
https://github.com/SashLilac/cambridge.git
synced 2024-11-22 18:29:02 -06:00
Adjusted 0 ARR to trigger onPieceMove multiple times
This commit is contained in:
parent
d350b25726
commit
99b15803ee
@ -163,24 +163,38 @@ end
|
|||||||
|
|
||||||
function Ruleset:movePiece(piece, grid, move, instant)
|
function Ruleset:movePiece(piece, grid, move, instant)
|
||||||
if not self:canPieceMove(piece, grid) then return end
|
if not self:canPieceMove(piece, grid) then return end
|
||||||
local x = piece.position.x
|
|
||||||
local was_drop_blocked = piece:isDropBlocked(grid)
|
local was_drop_blocked = piece:isDropBlocked(grid)
|
||||||
|
local offset = ({x=0, y=0})
|
||||||
|
local moves = 0
|
||||||
if move == "left" then
|
if move == "left" then
|
||||||
piece:moveInGrid({x=-1, y=0}, 1, grid, false)
|
offset.x = -1
|
||||||
|
moves = 1
|
||||||
elseif move == "right" then
|
elseif move == "right" then
|
||||||
piece:moveInGrid({x=1, y=0}, 1, grid, false)
|
offset.x = 1
|
||||||
|
moves = 1
|
||||||
elseif move == "speedleft" then
|
elseif move == "speedleft" then
|
||||||
piece:moveInGrid({x=-1, y=0}, grid.width, grid, instant)
|
offset.x = -1
|
||||||
|
moves = grid.width
|
||||||
elseif move == "speedright" then
|
elseif move == "speedright" then
|
||||||
piece:moveInGrid({x=1, y=0}, grid.width, grid, instant)
|
offset.x = 1
|
||||||
|
moves = grid.width
|
||||||
|
end
|
||||||
|
for i = 1, moves do
|
||||||
|
local x = piece.position.x
|
||||||
|
if moves ~= 1 then
|
||||||
|
piece:moveInGrid(offset, 1, grid, instant)
|
||||||
|
else
|
||||||
|
piece:moveInGrid(offset, 1, grid, false)
|
||||||
end
|
end
|
||||||
if piece.position.x ~= x then
|
if piece.position.x ~= x then
|
||||||
self:onPieceMove(piece, grid)
|
self:onPieceMove(piece, grid)
|
||||||
|
if piece.locked then break end
|
||||||
|
end
|
||||||
|
end
|
||||||
if not was_drop_blocked and piece:isDropBlocked(grid) then
|
if not was_drop_blocked and piece:isDropBlocked(grid) then
|
||||||
playSE("bottom")
|
playSE("bottom")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
function Ruleset:dropPiece(
|
function Ruleset:dropPiece(
|
||||||
inputs, piece, grid, gravity, drop_speed, drop_locked, hard_drop_locked,
|
inputs, piece, grid, gravity, drop_speed, drop_locked, hard_drop_locked,
|
||||||
|
Loading…
Reference in New Issue
Block a user