Skip to content

Commit

Permalink
Initial implementation of Last Input Controlled Priority.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tetro48 committed Feb 14, 2023
1 parent 33d11b5 commit ed45d16
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
23 changes: 23 additions & 0 deletions scene/game.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ function GameScene:render()
self.game:draw(self.paused)
end

local movement_directions = {"left", "right", "down", "up"}

function GameScene:onInputPress(e)
if (
self.game.game_over or self.game.completed
Expand Down Expand Up @@ -93,12 +95,33 @@ function GameScene:onInputPress(e)
end
elseif e.input and string.sub(e.input, 1, 5) ~= "menu_" and e.input ~= "frame_step" then
self.inputs[e.input] = true
if config.gamesettings["diagonal_input"] == 3 then
if (e.input == "left" or e.input == "right" or e.input == "down" or e.input == "up") then
for key, value in pairs(movement_directions) do
if value ~= e.input then
self.inputs[value] = false
end
end
self.first_input = self.first_input or e.input
end
end
end
end

function GameScene:onInputRelease(e)
if e.input and string.sub(e.input, 1, 5) ~= "menu_" then
self.inputs[e.input] = false
if config.gamesettings["diagonal_input"] == 3 then
if (e.input == "left" or e.input == "right" or e.input == "down" or e.input == "up") then

if self.first_input ~= nil and self.first_input ~= e.input then
self.inputs[self.first_input] = true
end
if self.first_input == e.input then
self.first_input = nil
end
end
end
end
end

Expand Down
2 changes: 1 addition & 1 deletion scene/game_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ConfigScene.options = {
{"world_reverse", "A Button Rotation", {"Left", "Auto", "Right"}},
{"spawn_positions", "Spawn Positions", {"Per ruleset", "In field", "Out of field"}},
{"save_replay", "Save Replays", {"On", "Off"}},
{"diagonal_input", "Diagonal Input", {"On", "Off"}},
{"diagonal_input", "Movement Type", {"8-way", "4-way Abs.", "4-way LICP"}},
{"das_last_key", "DAS Last Key", {"Off", "On"}},
{"buffer_lock", "Buffer Drop Type", {"Off", "Hold", "Tap"}},
{"synchroes_allowed", "Synchroes", {"Per ruleset", "On", "Off"}},
Expand Down
23 changes: 23 additions & 0 deletions scene/replay.lua
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ function ReplayScene:render()
end
end

local movement_directions = {"left", "right", "down", "up"}

function ReplayScene:onInputPress(e)
if (
e.input == "menu_back" or
Expand Down Expand Up @@ -175,6 +177,16 @@ function ReplayScene:onInputPress(e)
else resumeBGM() end
elseif e.input and string.sub(e.input, 1, 5) ~= "menu_" and self.rerecord and e.input ~= "frame_step" then
self.inputs[e.input] = true
if config.gamesettings["diagonal_input"] == 3 then
if (e.input == "left" or e.input == "right" or e.input == "down" or e.input == "up") then
for key, value in pairs(movement_directions) do
if value ~= e.input then
self.inputs[value] = false
end
end
self.first_input = self.first_input or e.input
end
end
elseif e.input == "hold" then
self.rerecord = true
savestate_frames = self.frames
Expand All @@ -199,6 +211,17 @@ end
function ReplayScene:onInputRelease(e)
if e.input and string.sub(e.input, 1, 5) ~= "menu_" and self.rerecord then
self.inputs[e.input] = false
if config.gamesettings["diagonal_input"] == 3 then
if (e.input == "left" or e.input == "right" or e.input == "down" or e.input == "up") then

if self.first_input ~= nil and self.first_input ~= e.input then
self.inputs[self.first_input] = true
end
if self.first_input == e.input then
self.first_input = nil
end
end
end
end
end

Expand Down

0 comments on commit ed45d16

Please sign in to comment.