Add the missing buffer logical code in training mode

This commit is contained in:
Squishy (C6H12O6+NaCl+H2O)
2024-04-12 21:01:43 +07:00
parent f56bde14b9
commit f8185d4f2d
2 changed files with 26 additions and 6 deletions

View File

@@ -29,13 +29,30 @@ function TrainingScene:new()
rotate_180=false,
hold=false,
}
self.inputs_waiting2trigger={ -- Used for buffering the input, in case the input is too fast (1f)
left=false,
right=false,
up=false,
down=false,
rotate_left=false,
rotate_left2=false,
rotate_right=false,
rotate_right2=false,
rotate_180=false,
hold=false,
}
self.paused = false
end
function TrainingScene:update()
local inputs = {}
for input, value in pairs(self.inputs) do
inputs[input] = value
if self.inputs_waiting2trigger[input] then
inputs[input]=true
self.inputs_waiting2trigger[input]=false
else
inputs[input] = value
end
end
self.game:update(inputs, self.ruleset)
self.game.grid:update()
@@ -52,6 +69,7 @@ function TrainingScene:onInputPress(e)
scene = TitleScene()
elseif e.input and string.sub(e.input, 1, 5) ~= "menu_" then
self.inputs[e.input] = true
self.inputs_waiting2trigger[e.input] = true
end
end