-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.lua
68 lines (50 loc) · 1.08 KB
/
main.lua
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
59
60
61
62
63
64
65
66
67
68
-- lovebird = require 'lovebird'
local Thread = require 'threads'
require 'animation'
require 'game.model'
require 'view'
require 'game-state'
local menu = MenuState:new()
local game = PlayingState:new()
local state
menu:init(game)
game:init(menu)
local function switchTo(newState)
state = newState
state:enter()
end
function love.load()
Thread.init()
initAnimation()
love.keyboard.setKeyRepeat(true)
menu:load()
game:load()
switchTo(game)
end
function love.mousepressed(x,y,b,t)
state:mousepressed(x,y,b,t)
end
function love.mousereleased(x,y,b,t)
state:mousereleased(x,y,b,t)
end
function love.mousemoved(x,y,dx,dy,t)
state:mousemoved(x,y,dx,dy,t)
end
function love.wheelmoved(x,y)
state:wheelmoved(x,y)
end
function love.draw()
love.graphics.push()
state:draw()
love.graphics.pop()
end
function love.keypressed(key,scan,isrepeat)
local newState = state:keypressed(key,scan,isrepeat)
if newState ~= nil then
switchTo(newState)
end
end
function love.update()
Thread.update()
state:update()
end