-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.lua
100 lines (78 loc) · 2.55 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
--[[
GD50
Angry Birds
Author: Colton Ogden
Released by Rovio in 2009, Angry Birds took the mobile gaming scene by storm back
when it was still arguably in its infancy. Using the simple gameplay mechanic of
slingshotting birds into fortresses of various materials housing targeted pigs,
Angry Birds succeeded with its optimized formula for on-the-go gameplay. It's an
excellent showcase of the ubiquitous Box2D physics library, the most widely used
physics library of its kind, which is also open source. This "clone" of Angry Birds
doesn't contain nearly the plethora of features as the original series of games
it's based on but does use Box2D to showcase the fundamental setup of what the game
looks like and how to use a subset of the physics library's features.
Music credit:
https://freesound.org/people/tyops/sounds/348166/
Artwork credit:
https://opengameart.org/content/physics-assets
]]
require 'src/Dependencies'
function love.load()
math.randomseed(os.time())
love.graphics.setDefaultFilter('nearest', 'nearest')
love.window.setTitle('Angry 50')
push:setupScreen(VIRTUAL_WIDTH, VIRTUAL_HEIGHT, WINDOW_WIDTH, WINDOW_HEIGHT, {
fullscreen = false,
vsync = true,
resizable = true
})
gStateMachine = StateMachine {
['start'] = function() return StartState() end,
['play'] = function() return PlayState() end
}
gStateMachine:change('start')
gSounds['music']:setLooping(true)
gSounds['music']:play()
love.keyboard.keysPressed = {}
love.mouse.keysPressed = {}
love.mouse.keysReleased = {}
paused = false
end
function push.resize(w, h)
push:resize(w, h)
end
function love.keypressed(key)
if key == 'p' then
paused = not paused
end
love.keyboard.keysPressed[key] = true
end
function love.mousepressed(x, y, key)
love.mouse.keysPressed[key] = true
end
function love.mousereleased(x, y, key)
love.mouse.keysReleased[key] = true
end
function love.keyboard.wasPressed(key)
return love.keyboard.keysPressed[key]
end
function love.mouse.wasPressed(key)
return love.mouse.keysPressed[key]
end
function love.mouse.wasReleased(key)
return love.mouse.keysReleased[key]
end
function love.update(dt)
if not paused then
gStateMachine:update(dt)
love.keyboard.keysPressed = {}
love.mouse.keysPressed = {}
love.mouse.keysReleased = {}
end
end
function love.draw()
push:start()
gStateMachine:render()
push:finish()
end