DAS priority reversal (#25)

* Reversed the priority of key presses when charging DAS.
* Made it an actual config option.
* Config should be false by default.
This commit is contained in:
Joe Zeng 2019-07-07 17:23:17 -04:00 committed by Ishaan Bhardwaj
parent 957802a78e
commit 8c1eaec1aa
2 changed files with 52 additions and 21 deletions

View File

@ -12,6 +12,7 @@ function love.load()
config["side_next"] = false config["side_next"] = false
config["reverse_rotate"] = true config["reverse_rotate"] = true
config["fullscreen"] = false config["fullscreen"] = false
config["das_last_key"] = false
love.window.setMode(love.graphics.getWidth(), love.graphics.getHeight(), {resizable = true}); love.window.setMode(love.graphics.getWidth(), love.graphics.getHeight(), {resizable = true});

View File

@ -223,8 +223,19 @@ function GameMode:onGameOver()
switchBGM(nil) switchBGM(nil)
end end
function GameMode:chargeDAS(inputs) -- DAS functions
if inputs[self.das.direction] == true then
function GameMode:startRightDAS()
self.move = "right"
self.das = { direction = "right", frames = 0 }
end
function GameMode:startLeftDAS()
self.move = "left"
self.das = { direction = "left", frames = 0 }
end
function GameMode:continueDAS()
local das_frames = self.das.frames + 1 local das_frames = self.das.frames + 1
if das_frames >= self:getDasLimit() then if das_frames >= self:getDasLimit() then
if self.das.direction == "left" then if self.das.direction == "left" then
@ -238,15 +249,34 @@ function GameMode:chargeDAS(inputs)
self.move = "none" self.move = "none"
self.das.frames = das_frames self.das.frames = das_frames
end end
elseif inputs["right"] == true then end
self.move = "right"
self.das = { direction = "right", frames = 0 } function GameMode:stopDAS()
elseif inputs["left"] == true then
self.move = "left"
self.das = { direction = "left", frames = 0 }
else
self.move = "none" self.move = "none"
self.das = { direction = "none", frames = -1 } self.das = { direction = "none", frames = -1 }
end
function GameMode:chargeDAS(inputs)
if config["das_last_key"] then
if inputs["right"] == true and self.das.direction ~= "right" and not self.prev_inputs["right"] then
self:startRightDAS()
elseif inputs["left"] == true and self.das.direction ~= "left" and not self.prev_inputs["left"] then
self:startLeftDAS()
elseif inputs[self.das.direction] == true then
self:continueDAS()
else
self:stopDAS()
end
else -- default behaviour, das first key pressed
if inputs[self.das.direction] == true then
self:continueDAS()
elseif inputs["right"] == true then
self:startRightDAS()
elseif inputs["left"] == true then
self:startLeftDAS()
else
self:stopDAS()
end
end end
end end