-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.lua
104 lines (85 loc) · 2.54 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
102
103
104
require("pgen")
require("util")
require("spatialgrid")
require("state_particleplayer")
require("state_fragments")
require("state_tester")
require("state_kaleidoscope")
require("state_derp")
globals = {
gamefont = nil
}
image = love.graphics.newImage("logo.png")
mousePosition = { 0, 0 }
canvas = nil
gamestate = StateFragments()
function love.load()
local glyphs = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-=_+|/\\:;'\"<>,.?"
globals.gameFont = love.graphics.newImageFont("font.png", glyphs, 2)
love.graphics.setDefaultFilter("nearest", "nearest")
-- love.mouse.setVisible(false)
-- effect = love.graphics.newShader("shaders/boxblur.frag")
-- effect = love.graphics.newShader("shaders/moonshine.frag")
canvas = love.graphics.newCanvas(800, 600)
end
local t = 0
function love.update(dt)
t = t + dt
-- effect:send("time", t)
gamestate:update(dt)
end
function love.draw()
-- Draw everything to the canvas
love.graphics.setCanvas(canvas)
love.graphics.clear()
love.graphics.setColor(1, 1, 1, 1)
love.graphics.setShader(effect)
-- love.graphics.draw(image, 20, 20)
gamestate:draw()
-- re-enable drawing to the main screen
love.graphics.setCanvas()
-- last but not least, draw the canvas to screen
love.graphics.draw(canvas)
end
function love.mousepressed(x, y, button, istouch, presses)
print(string.format("Click on %d, %d", x, y))
gamestate:mousePressed(x, y, button, istouch, presses)
end
function love.mousereleased(x, y, button, istouch, presses)
gamestate:mouseReleased(x, y, button, istouch, presses)
end
function love.mousemoved(x, y, dx, dy, istouch)
mousePosition = { x, y }
gamestate:mouseMoved(x, y, dx, dy, istouch)
end
function love.wheelmoved(x, y)
gamestate:mouseWheelMoved(x, y)
end
function love.keypressed(key)
if key == 'escape' then
love.event.quit()
elseif key == 'f' then
love.window.setFullscreen(not love.window.getFullscreen(), "desktop")
canvas = love.graphics.newCanvas(love.graphics.getWidth(), love.graphics.getHeight())
elseif key == 'f1' then
gamestate = StateParticlePlayer()
elseif key == 'f2' then
gamestate = StateFragments()
elseif key == 'f3' then
gamestate = StateTester()
elseif key == 'f4' then
gamestate = StateKaleidoscope()
elseif key == 'f5' then
gamestate = StateDerp()
elseif key == 'r' then
status, message = love.graphics.validateShader(false, "shaders/boxblur.frag")
print(status)
print(message)
if status then
effect = love.graphics.newShader("shaders/boxblur.frag")
end
end
gamestate:keyPressed(key)
end
function love.keyreleased(key)
end