-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.lua
executable file
·329 lines (325 loc) · 9.14 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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
require "jogo"
function love.load()
capa = love.graphics.newImage("images/images/capa.png")
start = love.graphics.newImage("start.png")
start_sel =love.graphics.newImage("images/start_sel.png")
options=love.graphics.newImage("images/options.png") -- botão opções
options_sel =love.graphics.newImage("images/options_sel.png") -- botão opções
options2=love.graphics.newImage("images/options2.png") --- menu opções
sound=love.graphics.newImage("images/sound.png")
sound_sel=love.graphics.newImage("images/sound_selected.png")
sound_on=love.graphics.newImage("images/sound_on.png")
sound_off=love.graphics.newImage("images/sound_off.png")
music=love.graphics.newImage("images/music.png")
music_sel=love.graphics.newImage("images/music_selected.png")
help =love.graphics.newImage("images/help.png") -- primeira tela
help_sel =love.graphics.newImage("images/help_selected.png")
back=love.graphics.newImage("images/back.png")
back_sel=love.graphics.newImage("images/back_selected.png")
help2=love.graphics.newImage("images/help2.png") --instruções
levels=love.graphics.newImage("images/interface_levels.png")
level1=love.graphics.newImage("images/LEVEL 1.png")
level2=love.graphics.newImage("images/LEVEL 2.png")
level3=love.graphics.newImage("images/LEVEL 3.png")
level4=love.graphics.newImage("images/LEVEL 4.png")
level5=love.graphics.newImage("images/LEVEL 5.png")
carrega_musica()
botao=0
gamestate=0
level=1
som=0
musica=0
end
function love.update(dt)
if gamestate == 4 then
jogo_update(dt)
end
if gamestate<4 or musica==1 then
muda_musica()
end
end
function love.keypressed(key)
if botao==5 then -- help
if key=="return" then
if gamestate==1 then
gamestate=2
elseif gamestate==2 then
gamestate=1
end
end
end
if botao==6 and key=="return" then--back
if gamestate==1 then
botao=2 gamestate=0
elseif gamestate==3 then
botao=1 gamestate=0 level=1
end
elseif gamestate==0 then --menu inicial
if botao==1 and key=="return" then --start
gamestate=3
end
if botao==2 and key=="return" then --options
gamestate=1 botao=3
end
if key=="left" then
if botao==0 then
botao=1
elseif botao==1 then
botao=2
elseif botao==2 then
botao=1
end
end
if key=="right" then
if botao==0 then
botao=2
elseif botao==2 then
botao=1
elseif botao==1 then
botao=2
end
end
elseif gamestate==1 then -- options
if key=="down" then
if botao==3 then
botao=4
elseif botao==4 then
botao=5
elseif botao==5 then
botao=6
elseif botao==6 then
botao=3
end
end
if botao==3 then
if key=="return" then
if som==0 then
som=1
elseif som==1 then
som=0
end
end
end
if botao==4 then
if key=="return" then
if musica==0 then
musica=1
elseif musica==1 then
musica=0
end
end
end
if key=="up" then
if botao==3 then
botao=6
elseif botao==6 then
botao=5
elseif botao==5 then
botao=4
elseif botao==4 then
botao=3
end
end
elseif gamestate==3 then -- seleção niveis
if key=="right" then
if level==1 then
level=2
elseif level==2 then
level=3
elseif level==3 then
level=4
elseif level==4 then
level=5
elseif level==5 then
botao= 6 level=0
elseif level==0 then
level=1 botao=0
end
end
if key=="left" then
if level==1 then
botao=6 level=0
elseif level==0 then
level=5 botao=0
elseif level==5 then
level=4
elseif level==4 then
level=3
elseif level==3 then
level=2
elseif level==2 then
level=1
end
end
if key=="return" and level ~=0 then
gamestate=4
fase = level
jogo_load()
end
if botao==6 and key=="return" then
gamestate=0 botao=1 level=0
end
elseif gamestate == 4 then -- Jogo
controle_keypressed(key)
--if key == "" then
--gamestate = 5
--end
--elseif gamestate == 5 then
end
if gamestate==4 then
if key == "escape" then
pause=1 -- menu pause
love.audio.pause()
end
if pause==1 and key=="down" then
if botaopause==0 then
botaopause=1
elseif botaopause==1 then
botaopause=2
elseif botaopause==2 then
botaopause=3
elseif botaopause==3 then
botaopause=4
elseif botaopause==4 then
botaopause=0
end
end
if pause==1 and key=="up" then
if botaopause==0 then
botaopause=4
elseif botaopause==4 then
botaopause=3
elseif botaopause==3 then
botaopause=2
elseif botaopause==2 then
botaopause=1
elseif botaopause==1 then
botaopause=0
end
end
if pause==1 and key=="return"then
if botaopause==0 then
pause=0
love.audio.resume()
elseif botaopause==1 then
if som==1 then
som=0
elseif som==0 then
som=1
end
elseif botaopause==2 then
if musica==1 then
musica=0
if fase == 1 then
music1:setVolume(1.0) ---manda tocar a música da fase
elseif fase == 2 then
music2:setVolume(1.0) ---manda tocar a música da fase
elseif fase == 3 then
music3:setVolume(1.0) ---manda tocar a música da fase
elseif fase == 4 then
music4:setVolume(1.0) ---manda tocar a música da fase
elseif fase == 5 then
music5:setVolume(1.0) ---manda tocar a música da fase
end
elseif musica==0 then
musica=1
if fase == 1 then
music1:setVolume(0.0) ---manda tocar a música da fase
elseif fase == 2 then
music2:setVolume(0.0) ---manda tocar a música da fase
elseif fase == 3 then
music3:setVolume(0.0) ---manda tocar a música da fase
elseif fase == 4 then
music4:setVolume(0.0) ---manda tocar a música da fase
elseif fase == 5 then
music5:setVolume(0.0) ---manda tocar a música da fase
end
end
elseif botaopause==3 then
gamestate=3 botaopause=0
elseif botaopause==4 then
gamestate=0 botao=1 botaopause=0 level=1
end
end
end
end
function love.draw()
if gamestate == 4 then
jogo_draw()
end
if gamestate<=2 then
love.graphics.draw(capa,0,0)
end
if gamestate==0 then
love.graphics.draw (start,60,500)
love.graphics.draw(options,525,500)
if botao==1 then
love.graphics.draw (start_sel,45,490)
end
if botao==2 then
love.graphics.draw(options_sel,510,490)
end
end
if gamestate==1 then
love.graphics.draw(options2,100,100)
love.graphics.draw(sound,347,217)
love.graphics.draw(music,352,280)
love.graphics.draw(help,326,347)
love.graphics.draw(back,529,424)
if som==0 then
love.graphics.draw(sound_on,519,200)
end
if som==1 then
love.graphics.draw(sound_off,519,200)
end
if musica==0 then
love.graphics.draw(sound_on,520,265)
end
if musica==1 then
love.graphics.draw(sound_off,520,265)
end
if botao==3 and gamestate==1 then
love.graphics.draw(sound_sel,347,217)
end
if botao==4 then
love.graphics.draw(music_sel,352,280)
end
if botao==5 then
love.graphics.draw(help_sel,326,347)
end
end
if gamestate==1 or gamestate==3 then
if botao==6 then
love.graphics.draw(back_sel,529,424)
end
end
if gamestate==2 and botao==5 then
love.graphics.draw(help2,100,100)
love.graphics.draw(back_sel,560,450)
end
if gamestate==3 then
love.graphics.draw(levels,0,0,0,1.345,1.5)
love.graphics.draw(back,660,540)
if botao==6 then
love.graphics.draw(back_sel,660,540)
end
if level==1 then
love.graphics.draw(level1,53,154,0,1.05,1.15)
end
if level==2 then
love.graphics.draw(level2,285,154,0,1.1,1.15)
end
if level==3 then
love.graphics.draw(level3,516,154,0,1.1,1.15)
end
if level==4 then
love.graphics.draw(level4,169,363,0,1.1,1.15)
end
if level==5 then
love.graphics.draw(level5,402,364,0,1.1,1.15)
end
if level==6 then
love.graphics.draw(back,670,540)
end
end
end