add mode switch
This commit is contained in:
parent
a4576b4233
commit
6e5f0f2029
@ -1,13 +1,36 @@
|
|||||||
local racing = require("src.modes.racing")
|
local mode = {
|
||||||
|
require("src.modes.racing"),
|
||||||
|
require("src.modes.raising_sim")
|
||||||
|
};
|
||||||
|
|
||||||
|
local mode_i = 1
|
||||||
|
|
||||||
function love.load()
|
function love.load()
|
||||||
racing.load()
|
mode[mode_i].load()
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.update(dt)
|
function love.update(dt)
|
||||||
racing.update(dt)
|
mode[mode_i].update(dt)
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.draw()
|
function love.draw()
|
||||||
racing.draw()
|
mode[mode_i].draw()
|
||||||
|
end
|
||||||
|
|
||||||
|
function love.keyreleased(key, scancode)
|
||||||
|
if (key == "right") then
|
||||||
|
mode_i = mode_i + 1
|
||||||
|
if (mode_i > 2) then
|
||||||
|
mode_i = 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
mode[mode_i].keyreleased(key, scancode)
|
||||||
|
end
|
||||||
|
|
||||||
|
function love.keypressed(key, scancode, isrepeat)
|
||||||
|
mode[mode_i].keypressed(key, scancode, isrepeat)
|
||||||
|
end
|
||||||
|
|
||||||
|
function love.mousereleased(x, y, button, istouch, presses)
|
||||||
|
mode[mode_i].mousereleased(x, y, button, istouch, presses)
|
||||||
end
|
end
|
||||||
|
|||||||
24
game/src/modes/mode.lua
Normal file
24
game/src/modes/mode.lua
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
local mode = {}
|
||||||
|
|
||||||
|
|
||||||
|
function mode.load()
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function mode.update(dt)
|
||||||
|
end
|
||||||
|
|
||||||
|
function mode.draw()
|
||||||
|
end
|
||||||
|
|
||||||
|
function mode.keyreleased(key, scancode)
|
||||||
|
end
|
||||||
|
|
||||||
|
function mode.keypressed(key, scancode, isrepeat)
|
||||||
|
end
|
||||||
|
|
||||||
|
function mode.mousereleased(x, y, button, istouch, presses)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
return mode
|
||||||
@ -60,4 +60,13 @@ function mode.draw()
|
|||||||
entities.racer:draw()
|
entities.racer:draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function mode.keyreleased(key, scancode)
|
||||||
|
end
|
||||||
|
|
||||||
|
function mode.keypressed(key, scancode, isrepeat)
|
||||||
|
end
|
||||||
|
|
||||||
|
function mode.mousereleased(x, y, button, istouch, presses)
|
||||||
|
end
|
||||||
|
|
||||||
return mode
|
return mode
|
||||||
|
|||||||
28
game/src/modes/raising_sim.lua
Normal file
28
game/src/modes/raising_sim.lua
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
local mode = {}
|
||||||
|
|
||||||
|
local entities = {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function mode.load()
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function mode.update(dt)
|
||||||
|
end
|
||||||
|
|
||||||
|
function mode.draw()
|
||||||
|
end
|
||||||
|
|
||||||
|
function mode.keyreleased(key, scancode)
|
||||||
|
end
|
||||||
|
|
||||||
|
function mode.keypressed(key, scancode, isrepeat)
|
||||||
|
end
|
||||||
|
|
||||||
|
function mode.mousereleased(x, y, button, istouch, presses)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
return mode
|
||||||
Loading…
x
Reference in New Issue
Block a user