-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.lua
101 lines (80 loc) · 2.45 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
101
--[[
SpaceLove
Rafael WO
]]
require 'src/Dependencies'
function love.load()
print(_VERSION)
math.randomseed(os.time())
love.graphics.setDefaultFilter('nearest', 'nearest')
love.audio.setVolume(0.7)
push:setupScreen(VIRTUAL_WIDTH, VIRTUAL_HEIGHT, WINDOW_WIDTH, WINDOW_HEIGHT, {
fullscreen = false,
vsync = true,
resizable = true
})
-- comment out the following lines to print the StateStack to the console
-- this requires game to be started with 'love . --console'
if DEBUG then
Event.on('stack-changed', function()
local stateString = ""
for k, state in ipairs(gStateStack.states) do
stateString = stateString .. " | " .. state.name
end
print(stateString)
end
)
end
love.graphics.setFont(gFonts['small'])
gStateStack = StateStack()
gStateStack:push(StartState({}))
love.keyboard.keysPressed = {}
love.keyboard.textInput = ""
METEOR_TYPES = getFrameNamesFromSheet('sheet', 'meteor')
EXPLOSION_BLAST_SHIP = getBlast(120)
EXPLOSION_BLAST_METEOR_SM = getBlast(50)
EXPLOSION_BLAST_METEOR_MD = getBlast(100)
EXPLOSION_BLAST_METEOR_LG = getBlast(150)
local menuBlinkInterval = 0.6
Timer.every(menuBlinkInterval, function()
Timer.tween(menuBlinkInterval / 2, {
[MENU_SELECTED_COLOR] = { r = 100/255, g = 100/255, b = 100/255}
}):finish(function ()
Timer.tween(menuBlinkInterval / 2, {
[MENU_SELECTED_COLOR] = {r = 150/255, g = 100/255, b = 255/255}
})
end)
end)
end
function love.resize(w, h)
push:resize(w, h)
end
function love.keypressed(key)
love.keyboard.keysPressed[key] = true
end
function love.keyboard.wasPressed(key)
return love.keyboard.keysPressed[key]
end
function love.textinput(t)
love.keyboard.textInput = t
end
function love.update(dt)
if DEBUG then
require("lovebird").update()
end
Timer.update(dt)
gStateStack:update(dt)
if love.keyboard.wasPressed('escape') then
love.event.quit()
end
love.keyboard.keysPressed = {}
love.keyboard.textInput = ""
end
function love.draw()
push:start()
gStateStack:render()
love.graphics.setColor(150/255, 150/255, 150/255, 255/255)
love.graphics.setFont(gFonts['default-small'])
love.graphics.printf(VERSION, 10, VIRTUAL_HEIGHT-25, VIRTUAL_WIDTH, 'left')
push:finish()
end