Files
tromi_mobile/scene/input_config.lua
Squishy (C6H12O6+NaCl+H2O) d0307c8765 first commit
2024-04-11 08:33:58 +07:00

61 lines
1.7 KiB
Lua

local ConfigScene = Scene:extend()
ConfigScene.title = "Input Config"
local minos = {'R_d', 'O_d', 'Y_d', 'G_d', 'C_d', 'B_d', 'M_d'}
local menu_screens = {
KeyConfigScene,
StickConfigScene
}
function ConfigScene:new(first_time)
self.menu_state = 1
if first_time then
self.first_time = true
else
self.first_time = false
end
end
function ConfigScene:update() end
function ConfigScene:render()
mainBackground()
if not self.first_time then
drawText("Which controls do you want to configure?", 80, 70, 1000)
else
drawText("Thanks for playing Tromi!", 80, 40, 1000)
drawText("Please begin by configuring your controls:", 80, 70, 1000)
end
love.graphics.setColor(1, 1, 1, 0.5)
love.graphics.rectangle("fill", 75, 118 + 50 * self.menu_state, 200, 33)
love.graphics.setColor(1, 1, 1, 1)
for i, screen in pairs(menu_screens) do
drawText(screen.title, 80, 120 + 50 * i, 200, "left")
end
end
function ConfigScene:changeOption(rel)
local len = table.getn(menu_screens)
self.menu_state = (self.menu_state + len + rel - 1) % len + 1
end
function ConfigScene:onInputPress(e)
if e.input == "menu_decide" or e.input == "rotate_left" or e.scancode == "return" then
scene = menu_screens[self.menu_state]()
elseif e.input == "up" or e.scancode == "up" then
self:changeOption(-1)
elseif e.input == "down" or e.scancode == "down" then
self:changeOption(1)
elseif config.input and (
e.input == "menu_back" or e.input == "rotate_right" or e.scancode == "backspace" or e.scancode == "delete"
) then
scene = TitleScene()
end
end
return ConfigScene