Thanks

Code: Select all
-- main.lua (still learning how to properly use "require" with my face)
function menu:gamepadpressed(joystick, button)
-- code to move cursor up and down in the menu
-- Act on menu selection if confirmation button is pressed
if joystick:isGamepadDown("a") then
menu:switchState(cursor.index)
end
end
function menu:switchState(index)
if index == 3 then
print("You selected : " .. options[index].label)
elseif index == 5 then
--menu:quit()
end
end
function menu:quit()
print("Quittin' time")
end
Code: Select all
-- main.lua, very bottom of the code
function love.load()
Gamestate.registerEvents()
Gamestate.switch(menu)
end
Code: Select all
local Gamestate = require("gamestate")
local Menu = require("r_menustate")
function love.quit()
print("love.quit(): Bye!")
end
function love.load()
Gamestate.registerEvents()
Gamestate.switch(Menu)
end
Code: Select all
-- r_menustate.lua
function menu:gamepadpressed(joystick, button)
-- cursor movement code
if joystick:isGamepadDown("a") then
menu:switchState(cursor.index)
end
end
function menu:switchState(index)
if index == 3 then
print("You selected : " .. options[index].label)
elseif index == 5 then
menu:quit()
end
end
function menu:quit()
-- calling this function with empty body does not result in love.quit() being called;
-- the statements inside the body are executed, but love.quit() never happens at the
-- end
end
Code: Select all
-- main.lua
local Gamestate = require("gamestate")
local Menu = require("r_menustate")
function love.load()
Gamestate.registerEvents{'draw', 'update', 'gamepadpressed', 'quit'}
Gamestate.switch(Menu)
end
--function love.quit()
--print("love.quit(): Bye!")
--end
Code: Select all
function scene:update(dt)
local dx, dy = player.x - camera.x, player.y - camera.y
camera:move(dx/2, dy/2)
camera:lockWindow(1000,0,2000,4000,0,0)
end
Users browsing this forum: No registered users and 3 guests