-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.lua
86 lines (71 loc) · 1.87 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
Gamestate = require 'libs.hump.gamestate'
Class = require 'libs.hump.class'
CScreen = require 'libs.cscreen.cscreen'
inspect = require 'libs.inspect.inspect'
Vector = require 'libs.hump.vector'
Timer = require 'libs.hump.timer'
Moonshine = require 'libs.moonshine'
w, h = 480, 320
love.event.pump()
love.mouse.setRelativeMode(true)
love.mouse.setVisible(false)
love.event.pump()
function colorBuilder(r, g, b, a)
return { r/255, g/255, b/255, (a or 255)/255 }
end
function yOnLine(x1, y1, x2, y2, x)
local m = (y2 - y1) / (x2 - x1)
local b = y1 - m*x1
return m*x+b
end
function distanceBetweenPoints(x1, y1, x2, y2)
return math.sqrt(math.pow(x2 - x1,2) + math.pow(y2 - y1,2))
end
titleTransitionLock = false
pauseTransitionLock = false
gameOverTransitionLock = false
game = require 'gamestates.game'
function love.load()
CScreen.init(w, h, true)
Gamestate.registerEvents()
Gamestate.switch(game)
end
screenshots = 0
function love.keypressed(key)
if key == "escape" then
love.event.push("quit")
elseif key == "1" then
local newFS = not love.window.getFullscreen()
love.window.setFullscreen(newFS)
CScreen.update(w*2, h*2)
initEffect()
save.fullscreen = newFS
save:writeOut()
elseif key == "2" then
if love.window.getFullscreen() then
save.effect = not save.effect
save:writeOut()
end
elseif key == "3" then
love.graphics.captureScreenshot("screenshot"..screenshots..".png")
screenshots = screenshots + 1
elseif key == "`" then
dev = not dev
end
end
function love.resize(width, height)
CScreen.update(width, height)
end
function love.mousemoved(x, y, dx, dy)
if player then
player:mouseMoved(x, y, dx, dy)
end
end
function love.mousepressed(x, y, button)
if player then
player:mousePressed(x, y, button)
end
end
-- figure out
-- "expired" text when multiplier expires
-- jetpack momentum indicator