-
Notifications
You must be signed in to change notification settings - Fork 0
/
menu.lua
executable file
·286 lines (258 loc) · 8.84 KB
/
menu.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
function menu_load()
gamestate = "logo"
creditstext = {
"'Tm and C2011 sy,not",
"tetris 2 licensed to",
" stabyourself.net ",
" and ",
" sub-licensed to ",
" maurice. ",
" ",
" C2011 stabyourself ",
" dot net. ",
" ",
" ",
"all rights reserved.",
" ",
" original concept, ",
" design and program ",
"by alexey pazhitnov#"
}
logotime = 0
bootsoundplayed = false
oldtime = love.timer.getTime()
end
function menu_draw()
--FULLSCREEN OFFSET
if fullscreen then
love.graphics.translate(fullscreenoffsetX, fullscreenoffsetY)
end
if gamestate == "logo" then
if logotime <= logoduration then
love.graphics.draw(stabyourselflogo, 7 * scale, math.floor(-22 * scale + 80 * (logotime / logoduration) * scale), 0, scale, scale)
else
love.graphics.draw(stabyourselflogo, 7 * scale, math.floor(58 * scale), 0, scale, scale)
end
elseif gamestate == "credits" then ------------
for i, v in pairs(creditstext) do
love.graphics.print(v, 0, i * 8 * scale, 0, scale)
end
love.graphics.draw(logo, 32 * scale, 80 * scale, 0, scale)
------------------------------------------
elseif gamestate == "title" then ----------
love.graphics.draw(title, 0, 0, 0, scale)
if playerselection == 1 then
love.graphics.print(">", 1 * scale, 124 * scale, 0, scale)
elseif playerselection == 2 then
love.graphics.print(">", 47 * scale, 124 * scale, 0, scale)
else
love.graphics.print(">", 93 * scale, 124 * scale, 0, scale)
end
------------------------------------------
elseif gamestate == "menu" or gamestate == "highscoreentry" then
love.graphics.draw(gametype, 0, 0, 0, scale)
if selection > 2 then
if gameno == 1 then
love.graphics.print("normal", 24 * scale, 26 * scale, 0, scale)
else
love.graphics.print("stack ", 88 * scale, 26 * scale, 0, scale)
end
else
if musicno == 1 then
love.graphics.print("a-type", 24 * scale, 60 * scale, 0, scale)
elseif musicno == 2 then
love.graphics.print("b-type", 88 * scale, 60 * scale, 0, scale)
elseif musicno == 3 then
love.graphics.print("c-type", 24 * scale, 76 * scale, 0, scale)
else
love.graphics.print(" off ", 88 * scale, 76 * scale, 0, scale)
end
end
if selectblink == true then
if selection == 1 then
love.graphics.print("normal", 24 * scale, 26 * scale, 0, scale)
elseif selection == 2 then
love.graphics.print("stack ", 88 * scale, 26 * scale, 0, scale)
elseif selection == 3 then
love.graphics.print("a-type", 24 * scale, 60 * scale, 0, scale)
elseif selection == 4 then
love.graphics.print("b-type", 88 * scale, 60 * scale, 0, scale)
elseif selection == 5 then
love.graphics.print("c-type", 24 * scale, 76 * scale, 0, scale)
elseif selection == 6 then
love.graphics.print(" off ", 88 * scale, 76 * scale, 0, scale)
end
end
----------------------------------------------
elseif gamestate == "multimenu" then
love.graphics.draw(mpmenu, 0, 0, 0, scale)
if selection > 2 then
if gameno == 1 then
love.graphics.print("stack", 28 * scale, 47 * scale, 0, scale)
else
love.graphics.print("invade", 88 * scale, 47 * scale, 0, scale)
end
else
if musicno == 1 then
love.graphics.print("a-type", 24 * scale, 81 * scale, 0, scale)
elseif musicno == 2 then
love.graphics.print("b-type", 88 * scale, 81 * scale, 0, scale)
elseif musicno == 3 then
love.graphics.print("c-type", 24 * scale, 97 * scale, 0, scale)
else
love.graphics.print(" off ", 88 * scale, 97 * scale, 0, scale)
end
end
if selectblink == true then
if selection == 1 then
love.graphics.print("stack", 28 * scale, 47 * scale, 0, scale)
elseif selection == 2 then
love.graphics.print("invade", 88 * scale, 47 * scale, 0, scale)
elseif selection == 3 then
love.graphics.print("a-type", 24 * scale, 81 * scale, 0, scale)
elseif selection == 4 then
love.graphics.print("b-type", 88 * scale, 81 * scale, 0, scale)
elseif selection == 5 then
love.graphics.print("c-type", 24 * scale, 97 * scale, 0, scale)
elseif selection == 6 then
love.graphics.print(" off ", 88 * scale, 97 * scale, 0, scale)
end
end
--win counter
if p1wins < 10 then
love.graphics.print("0" .. p1wins, 15 * scale, 31 * scale, 0, scale)
else
love.graphics.print(p1wins, 15 * scale, 31 * scale, 0, scale)
end
if p2wins < 10 then
love.graphics.print("0" .. p2wins, 129 * scale, 31 * scale, 0, scale)
else
love.graphics.print(p2wins, 129 * scale, 31 * scale, 0, scale)
end
end
if gamestate == "menu" or gamestate == "highscoreentry" then
for i = 1, 3 do
if tonumber(highscore[i]) > 0 then
--name
love.graphics.print(string.lower(string.sub(highscorename[i], 1, 6)), 33 * scale, 110 * scale + 8 * scale * (i - 1), 0, scale)
--score
offsetX = 0
for i = 1, string.sub(tostring(highscore[i]), 1, 6):len() - 1 do
offsetX = offsetX - 8 * scale
end
love.graphics.print(string.sub(tostring(highscore[i]), 1, 6), 137 * scale + offsetX, 110 * scale + 8 * scale * (i - 1), 0, scale)
end
end
end
if gamestate == "highscoreentry" then
if highscorename[highscoreno]:len() < 6 then
offsetX = 0
for i = 1, highscorename[highscoreno]:len() do
offsetX = offsetX + 8 * scale
end
if cursorblink == true then
love.graphics.print("_", 33 * scale + offsetX, 110 * scale + 8 * scale * (highscoreno - 1), 0, scale)
else
love.graphics.print(" ", 33 * scale + offsetX, 110 * scale + 8 * scale * (highscoreno - 1), 0, scale)
end
else
if cursorblink == true then
love.graphics.print("_", 33 * scale + 8 * scale * 5, 110 * scale + 8 * scale * (highscoreno - 1), 0, scale)
end
end
end
if gamestate == "options" then
love.graphics.draw(optionsmenu, 0, 0, 0, scale, scale)
love.graphics.draw(rainbowgradient, 73 * scale, 33 * scale, 0, scale, scale)
--volume slider
love.graphics.draw(volumeslider, 71 * scale + round(76 * volume) * scale, 15 * scale, 0, scale, scale)
--hue slider
love.graphics.draw(volumeslider, 71 * scale + round(76 * hue * scale), 31 * scale, 0, scale, scale)
--blend out unavailable scales
for i = 2, 7 do
if i > maxscale then
love.graphics.print(" ", 75 * scale + (i - 1) * 11 * scale, 50 * scale, 0, scale)
end
end
--current scale
if fullscreen == false then
love.graphics.print(scale, 75 * scale + (scale - 1) * 11 * scale, 50 * scale, 0, scale)
end
--fullscreen
if fullscreen then
love.graphics.print("yes", 96 * scale, 66 * scale, 0, scale)
else
love.graphics.print("no", 133 * scale, 66 * scale, 0, scale)
end
if selectblink then
love.graphics.print(optionschoices[optionsselection], 19 * scale, 18 * scale + (optionsselection - 1) * 16 * scale, 0, scale)
end
end
------------------------------------------
end
function menu_update(dt)
if gamestate == "logo" then
logotime = logotime + dt
if logotime >= logoduration and bootsoundplayed == false then
love.audio.stop(boot)
love.audio.play(boot)
bootsoundplayed = true
end
if logotime >= logoduration + logodelay then
oldtime = love.timer.getTime()
gamestate = "credits"
end
end
if gamestate == "credits" then
currenttime = love.timer.getTime()
if currenttime - oldtime > creditsdelay then
gamestate = "title"
love.graphics.setBackgroundColor(0, 0, 0)
love.audio.play(musictitle)
end
end
if gamestate == "menu" or gamestate == "multimenu" or gamestate == "options" then
currenttime = love.timer.getTime()
if currenttime - oldtime > selectblinkrate then -- TODO: error about oldtime being nil here sometimes
selectblink = not selectblink
oldtime = currenttime
end
end
if gamestate == "options" then
if optionsselection == 2 then
if love.keyboard.isDown("left") then
if hue > 0 then
hue = hue - 0.5 * dt
if hue < 0 then
hue = 0
end
optionsmenu = newPaddedImage("graphics/options.png"); optionsmenu:setFilter("nearest", "nearest")
volumeslider = newPaddedImage("graphics/volumeslider.png"); volumeslider:setFilter("nearest", "nearest")
end
elseif love.keyboard.isDown("right") then
if hue < 1 then
hue = hue + 0.5 * dt
if hue > 1 then
hue = 1
end
optionsmenu = newPaddedImage("graphics/options.png"); optionsmenu:setFilter("nearest", "nearest")
volumeslider = newPaddedImage("graphics/volumeslider.png"); volumeslider:setFilter("nearest", "nearest")
end
end
end
end
if gamestate == "highscoreentry" then
currenttime = love.timer.getTime()
if currenttime - oldtime > cursorblinkrate then
cursorblink = not cursorblink
oldtime = currenttime
end
if currenttime - highscoremusicstart > 1.2 then
if musicchanged == false then
musicchanged = true
love.audio.stop(highscoreintro)
love.audio.play(musichighscore)
end
end
end
end