scenes = {} local select_character = { selected = 1, options = { {text = "Warrior"}, {text = "Mage"}, {text = "Rogue"} } } local main = { selected = 1, options = { {text = "Start Game", next_scene = select_character}, {text = "Quit"} } } select_character.draw = function() for i, v in ipairs(select_character.options) do if i == select_character.selected then love.graphics.print({{255, 255, 0}, v.text}, 200, 100 + (15 * i)) else love.graphics.print(v.text, 200, 100 + (15 * i)) end end end select_character.keypressed = function(key) if key == "up" then select_character.selected = select_character.selected + 1 if select_character.selected > #select_character.options then select_character.selected = 1 end elseif key == "down" then select_character.selected = select_character.selected - 1 if select_character.selected < 1 then select_character.selected = #select_character.options end elseif key == "return" then local next = select_character.options[select_character.selected].next_scene if next then table.insert(scenes, next) else table.remove(scenes) end end end main.draw = function() for i, v in ipairs(main.options) do if i == main.selected then love.graphics.print({{255, 255, 0}, v.text}, 200, 100 + (15 * i)) else love.graphics.print(v.text, 200, 100 + (15 * i)) end end end main.keypressed = function(key) if key == "up" then main.selected = main.selected + 1 if main.selected > #main.options then main.selected = 1 end elseif key == "down" then main.selected = main.selected - 1 if main.selected < 1 then main.selected = #main.options end elseif key == "return" then local next = main.options[main.selected].next_scene if next then table.insert(scenes, next) else table.remove(scenes) end end end table.insert(scenes, main) return scenes