Added extra buttons:

- Implemented retry button*
- Escape on mode select sends you to title screen
- Escape on title screen closes the game
- Added "Exit Game" entry on title screen, closes the game when selected

*Pardon my angry comment in `scene/game.lua`.
This commit is contained in:
Oshisaure
2020-10-08 04:56:46 +01:00
parent a4984fd687
commit 5606251ea7
8 changed files with 43 additions and 2 deletions

23
scene/exit.lua Normal file
View File

@@ -0,0 +1,23 @@
local ExitScene = Scene:extend()
require 'load.save'
ExitScene.title = "Exit Game"
function ExitScene:new()
end
function ExitScene:update()
love.event.quit()
end
function ExitScene:render()
end
function ExitScene:changeOption(rel)
end
function ExitScene:onKeyPress(e)
end
return ExitScene

View File

@@ -57,11 +57,21 @@ end
function GameScene:onKeyPress(e)
if (self.game.completed) and
e.scancode == "return" and e.isRepeat == false then
(e.scancode == "return" or e.scancode == "escape") and e.isRepeat == false then
highscore_entry = self.game:getHighscoreData()
highscore_hash = self.game.hash .. "-" .. self.ruleset.hash
submitHighscore(highscore_hash, highscore_entry)
scene = ModeSelectScene()
elseif (e.scancode == config.input.retry) then
-- fuck this, this is hacky but the way this codebase is setup prevents anything else
-- it seems like all the values that get touched in the child gamemode class
-- stop being linked to the values of the GameMode superclass because of how `mt.__index` works
-- not even sure this is the actual problem, but I don't want to have to rebuild everything about
-- the core organisation of everything. this hacky way will have to do until someone figures out something.
love.keypressed("escape", "escape", false)
love.keypressed("return", "return", false)
elseif e.scancode == "escape" then
scene = ModeSelectScene()
end
end

View File

@@ -15,6 +15,7 @@ local configurable_inputs = {
"rotate_right2",
"rotate_180",
"hold",
"retry",
}
function ConfigScene:new()

View File

@@ -100,6 +100,8 @@ function ModeSelectScene:onKeyPress(e)
elseif (e.scancode == config.input["left"] or e.scancode == "left") or
(e.scancode == config.input["right"] or e.scancode == "right") then
self:switchSelect()
elseif e.scancode == "escape" then
scene = TitleScene()
end
end

View File

@@ -3,6 +3,7 @@ local TitleScene = Scene:extend()
local main_menu_screens = {
ModeSelectScene,
InputConfigScene,
ExitScene,
}
function TitleScene:new()
@@ -43,6 +44,8 @@ function TitleScene:onKeyPress(e)
self:changeOption(-1)
elseif (e.scancode == config.input["down"] or e.scancode == "down") and e.isRepeat == false then
self:changeOption(1)
elseif e.scancode == "escape" and e.isRepeat == false then
love.event.quit()
end
end