-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.lua
More file actions
58 lines (42 loc) · 1.14 KB
/
main.lua
File metadata and controls
58 lines (42 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
--[[
Space Invaders
Author: Colton Ogden
cogden@cs50.harvard.edu
]]
require 'src/Dependencies'
function love.load()
love.window.setTitle('Space Invaders')
gFont = love.graphics.newFont('fonts/pressstart.ttf', 8)
love.graphics.setFont(gFont)
math.randomseed(os.time())
push:setupScreen(VIRTUAL_WIDTH, VIRTUAL_HEIGHT, WINDOW_WIDTH, WINDOW_HEIGHT, {
fullscreen = false,
vsync = true,
resizable = true
})
gStateMachine = StateMachine {
['title'] = function() return TitleState() end,
['play'] = function() return PlayState() end,
['game-over'] = function() return GameOverState() end
}
gStateMachine:change('title')
love.keyboard.keysPressed = {}
end
function love.update(dt)
gStateMachine:update(dt)
love.keyboard.keysPressed = {}
end
function love.keypressed(key)
if key == 'escape' then
love.event.quit()
end
love.keyboard.keysPressed[key] = true
end
function love.keyboard.wasPressed(key)
return love.keyboard.keysPressed[key]
end
function love.draw()
push:start()
gStateMachine:render()
push:finish()
end