Started implementing game states and intro.
This commit is contained in:
66
src/intro.lua
Normal file
66
src/intro.lua
Normal file
@@ -0,0 +1,66 @@
|
||||
------------------------------------------------------------------------------
|
||||
-- Imports
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
local love = require 'love'
|
||||
local make_class = require 'src.classes'
|
||||
local GameState = require 'src.gstate'
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- Class definitions
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
local Intro = make_class(GameState)
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- Class methods
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
function Intro:_init(name, index)
|
||||
-- Call super-class constructor.
|
||||
GameState._init(self, name, index)
|
||||
|
||||
-- Attribute definitions
|
||||
self.skip = false
|
||||
end
|
||||
|
||||
|
||||
function Intro:load()
|
||||
self.background = love.graphics.newImage('imgs/cpu.png')
|
||||
self.valid = true
|
||||
end
|
||||
|
||||
|
||||
function Intro:update(_)
|
||||
if not self.skip then return self.index else return 0 end
|
||||
end
|
||||
|
||||
|
||||
function Intro:draw()
|
||||
if self.valid then
|
||||
love.graphics.draw(self.background, 0, 0)
|
||||
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 Intro:unload()
|
||||
self.background = nil
|
||||
self.valid = false
|
||||
end
|
||||
|
||||
|
||||
function Intro:keypressed(_)
|
||||
self.skip = true
|
||||
end
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- Module return
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
return Intro
|
||||
Reference in New Issue
Block a user