Added intro game state and placeholder assets.
This commit is contained in:
67
main.lua
67
main.lua
@@ -14,14 +14,33 @@ local Fader = require 'src.fader'
|
||||
Current_state = 1
|
||||
Fade = Fader()
|
||||
Change_state = false
|
||||
Debug = false
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- Helper methods
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
local function parse_args(args)
|
||||
for _, v in pairs(args) do
|
||||
|
||||
-- Enable debug mode.
|
||||
if v == '-debug' then Debug = true end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- Game methods
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
function love.load()
|
||||
function love.load(args)
|
||||
parse_args(args)
|
||||
|
||||
-- Load the assets of the intro game state.
|
||||
game_states[Current_state]:load()
|
||||
|
||||
-- Call a fade in after the intro assets are loaded.
|
||||
Fade:fade_in()
|
||||
end
|
||||
|
||||
@@ -61,21 +80,43 @@ function love.draw()
|
||||
love.graphics.clear()
|
||||
game_states[Current_state]:draw()
|
||||
Fade:draw()
|
||||
end
|
||||
|
||||
|
||||
function love.keypressed(key)
|
||||
-- Send events to the active game state if there is no fade active.
|
||||
if Fade.done then
|
||||
game_states[Current_state]:keypressed(key)
|
||||
if Debug then
|
||||
love.graphics.print(string.format('OS: %s', love.system.getOS()), 5, 5)
|
||||
love.graphics.print(string.format('Love version: %s', love.getVersion()), 5, 15)
|
||||
love.graphics.print(string.format('Memory usage: %s KiB', love.system.getMemUsage()), 5, 25)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function love.mousemoved(x, y)
|
||||
function love.keypressed(key, code, isrepeat)
|
||||
-- Send events to the active game state if there is no fade active.
|
||||
if Fade.done then
|
||||
game_states[Current_state]:mousemoved(x, y)
|
||||
game_states[Current_state]:keypressed(key, code, isrepeat)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function love.keyreleased(key, code)
|
||||
-- Send events to the active game state if there is no fade active.
|
||||
if Fade.done then
|
||||
game_states[Current_state]:keyreleased(key, code)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function love.textinput(text)
|
||||
-- Send events to the active game state if there is no fade active.
|
||||
if Fade.done then
|
||||
game_states[Current_state]:textinput(text)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function love.mousemoved(x, y, dx, dy)
|
||||
-- Send events to the active game state if there is no fade active.
|
||||
if Fade.done then
|
||||
game_states[Current_state]:mousemoved(x, y, dx, dy)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -86,3 +127,11 @@ function love.mousepressed(x, y, btn)
|
||||
game_states[Current_state]:mousemoved(x, y, btn)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function love.mousereleased(x, y, btn)
|
||||
-- Send events to the active game state if there is no fade active.
|
||||
if Fade.done then
|
||||
game_states[Current_state]:mousereleased(x, y, btn)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user