-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.lua
168 lines (162 loc) · 4.53 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
Object = require "libs/classic"
require "libs/fx"
require "libs/actions"
--require "libs/scrollingstring"
--OBJECTS
require "objects/gerard"
require "objects/button"
require "objects/background"
require "objects/fps"
function love.load()
moonshine = require "libs/moonshine"
effect = moonshine(moonshine.effects.scanlines)
love.audio.setEffect('echo',
{
type = 'echo',
delay = 1,
tapdelay = 5,
damping = 0,
feedback = 1,
spread = 3
})
love.audio.setEffect('distor', {
type = 'distortion',
gain = .3,
edge = .100,
})
img = love.graphics.newImage('assets/ger1.png')
gero = Gerard(img)
appliedFX = {}
gerards = {}
table.insert(gerards,gero)
song = love.audio.newSource( "assets/hola.ogg", "static" )
song:setLooping(true)
song:play()
buttons = {}
buttonInit()
background = Background()
fpsbar = FPSbar()
--scrolling text
--str = ScrollingString("Is this a long string or what? what is happening i don't know i'm out you fucker",300,300)
end
function love.update(dt)
for i=1,#gerards do
gerards[i]:update(dt)
end
for i=1,#buttons do
buttons[i]:update(dt)
end
background:update(dt)
fpsbar:update()
--str:update(dt)
end
function love.draw()
background:draw()
--effect(function()
for i=1,#gerards do
gerards[i]:draw()
end
--end)
love.graphics.setColor(223/255, 113/255, 38/255,1)
love.graphics.rectangle("fill",0,0,128,love.graphics.getHeight())
love.graphics.rectangle("fill",0,love.graphics.getHeight()-128,love.graphics.getWidth(),128)
love.graphics.setColor(1,1,1,1)
for i=1,#buttons do
buttons[i]:draw()
end
fpsbar:draw()
--str:draw()
end
function love.keypressed(key,scancode,isrepeat)
if key == "up" then
end
if key == "down" then
end
if key == "left" then
end
if key == "right" then
end
if key == "space" then
end
end
function activateEffect(name)
if findFX(name) > 0 then
love.audio.setEffect(name,false)
table.remove(appliedFX,(findFX(name)))
else
table.insert(appliedFX,name)
love.audio.setEffect(name,fx[name])
song:setEffect(name)
end
end
function love.mousepressed(x,y,button,istouch)
checkCollisions(x,y,button)
end
function checkCollisions(x,y,button)
clickedButton = false
for i=#buttons,1,-1 do
if x >buttons[i].x and
x < buttons[i].x+buttons[i].width and
y > buttons[i].y and
y < buttons[i].y+buttons[i].width then
buttons[i]:click()
clickedButton = true
break
end
end
if clickedButton == false then
if button == 2 then
for i=#gerards,1,-1 do
if x >gerards[i].x-128 and
x < gerards[i].x-128+img:getWidth() and
y > gerards[i].y-140 and
y < gerards[i].y-140+img:getHeight() then
table.remove(gerards,i)
break
end
end
else
addGerard(x,y)
end
end
end
function buttonInit()
h=love.graphics.getHeight()
but = Button("assets/button-background.png",0,h-600)
but.action= function () background:changeMode() end
table.insert(buttons,but)
but = Button(nil,0,h-512)
but.action= function () changeColor() end
table.insert(buttons,but)
but = Button("assets/button-morejeff.png",0,h-384)
but.action= function () addGerard() end
table.insert(buttons,but)
but = Button("assets/button-lessjeff.png",0,h-256)
but.action= function () lessGerard() end
table.insert(buttons,but)
but = Button("assets/button-move.png",0,h-128)
but.isSwitch = true
but.action= function () moveGerards() end
but.inaction= function () moveGerards() end
table.insert(buttons,but)
--AUDIO BUTTONS
but = Button("assets/button-pitchdown.png",128,h-128)
but.action= function () modPitch(-0.1) end
table.insert(buttons,but)
but = Button("assets/button-pitchup.png",256,h-128)
but.action= function () modPitch(0.1) end
table.insert(buttons,but)
but = Button("assets/button-echo.png",384,h-128)
but.action= function () activateEffect("echo") end
but.inaction = function() activateEffect("echo") end
but.isSwitch = true
table.insert(buttons,but)
but = Button("assets/button-distor.png",512,h-128)
but.action= function () activateEffect("distor") end
but.inaction = function() activateEffect("distor") end
but.isSwitch = true
table.insert(buttons,but)
but = Button("assets/button-reset.png",640,h-128)
but.action= function () reset() end
table.insert(buttons,but)
end