Added an option to control buffer locking.

You can now choose if you want a drop input
during ARE to lock the piece on the first frame it is active.
pull/13/head
Ishaan Bhardwaj 2021-01-06 16:06:17 -05:00
parent 0d13a9f236
commit 84634d6933
3 changed files with 43 additions and 3 deletions

View File

@ -16,6 +16,7 @@ ConfigScene.options = {
{"smooth_movement", "Smooth Piece Drop", false, {"On", "Off"}},
{"synchroes_allowed", "Synchroes", false, {"Per ruleset", "On", "Off"}},
{"diagonal_input", "Diagonal Input", false, {"On", "Off"}},
{"buffer_lock", "Buffer Lock Inputs", false, {"On", "Off"}},
{"sfx_volume", "SFX", true, "sfxSlider"},
{"bgm_volume", "BGM", true, "bgmSlider"},
}
@ -55,7 +56,7 @@ function ConfigScene:render()
--Lazy check to see if we're on the SFX or BGM slider. Probably will need to be rewritten if more options get added.
love.graphics.setColor(1, 1, 1, 0.5)
if not ConfigScene.options[self.highlight][3] then
love.graphics.rectangle("fill", 20, 98 + self.highlight * 20, 170, 22)
love.graphics.rectangle("fill", 25, 98 + self.highlight * 20, 170, 22)
else
love.graphics.rectangle("fill", 65 + (1+self.highlight-#self.options) * 300, 322, 215, 33)
end

View File

@ -327,6 +327,12 @@ function GameMode:processDelays(inputs, ruleset, drop_speed)
playedGoSE = false
end
if self.ready_frames > 0 then
if not self.prev_inputs["up"] and inputs["up"] then
self.buffer_hard_drop = true
end
if not self.prev_inputs["down"] and inputs["down"] then
self.buffer_soft_drop = true
end
if not playedReadySE then
playedReadySE = true
playSEOnce("ready")
@ -340,6 +346,12 @@ function GameMode:processDelays(inputs, ruleset, drop_speed)
self:initializeOrHold(inputs, ruleset)
end
elseif self.lcd > 0 then
if not self.prev_inputs["up"] and inputs["up"] then
self.buffer_hard_drop = true
end
if not self.prev_inputs["down"] and inputs["down"] then
self.buffer_soft_drop = true
end
self.lcd = self.lcd - 1
self:areCancel(inputs, ruleset)
if self.lcd == 0 then
@ -350,6 +362,12 @@ function GameMode:processDelays(inputs, ruleset, drop_speed)
end
end
elseif self.are > 0 then
if not self.prev_inputs["up"] and inputs["up"] then
self.buffer_hard_drop = true
end
if not self.prev_inputs["down"] and inputs["down"] then
self.buffer_soft_drop = true
end
self.are = self.are - 1
self:areCancel(inputs, ruleset)
if self.are == 0 then
@ -403,8 +421,20 @@ function GameMode:initializeNextPiece(inputs, ruleset, piece_data, generate_next
self.prev_inputs, self.move,
self:getLockDelay(), self:getDropSpeed(),
self.lock_drop, self.lock_hard_drop, self.big_mode,
self.irs
self.irs, self.buffer_hard_drop, self.buffer_soft_drop,
self.lock_on_hard_drop, self.lock_on_soft_drop
)
if self.buffer_hard_drop then
self.buffer_hard_drop = false
self:onHardDrop(self.piece.position.y - (
self.big_mode and
ruleset.big_spawn_positions[self.piece.shape].y or
ruleset.spawn_positions[self.piece.shape].y)
)
end
if self.buffer_soft_drop then
self.buffer_soft_drop = false
end
if self.lock_drop then
self.drop_locked = true
end

View File

@ -181,7 +181,9 @@ function Ruleset:getDefaultOrientation() return 1 end
function Ruleset:initializePiece(
inputs, data, grid, gravity, prev_inputs,
move, lock_delay, drop_speed,
drop_locked, hard_drop_locked, big, irs
drop_locked, hard_drop_locked, big, irs,
buffer_hard_drop, buffer_soft_drop,
lock_on_hard_drop, lock_on_soft_drop
)
local spawn_positions
if big then
@ -206,6 +208,13 @@ function Ruleset:initializePiece(
self:rotatePiece(inputs, piece, grid, {}, true)
end
self:dropPiece(inputs, piece, grid, gravity, drop_speed, drop_locked, hard_drop_locked)
if (buffer_hard_drop and config.gamesettings.buffer_lock == 1) then
piece:dropToBottom(grid)
if lock_on_hard_drop then piece.locked = true end
end
if (buffer_soft_drop and lock_on_soft_drop and piece:isDropBlocked(grid) and config.gamesettings.buffer_lock == 1) then
piece.locked = true
end
return piece
end