-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmenustate.lua
More file actions
257 lines (213 loc) · 5.34 KB
/
menustate.lua
File metadata and controls
257 lines (213 loc) · 5.34 KB
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
--[[
This software is released under the MIT License. See LICENSE.txt for details.
Also, on a non-legal note: I do not recommend reading my code, especially not for educative
purposes. It was written over like three years, and I often forgot how I implemented several
things over time. Also, I was mostly drunk and listening to the Katamari Damacy soundtrack.
So yeah.
]]
menuClass = stateClass:newSubClass()
local n,m
pron = 1 --pron är banans nummer, relativt världen
local diffs = worlds
local nlvls = 7
function getNewHighscore()
local hs = {}
for i=1,#worlds do
local lol = {}
for j=1,7 do
lol[j] = 99
end
hs[worlds[i]] = lol
end
return hs
end
function menuClass:setNM(argn)
if argn >= 1 and argn <= #diffs*nlvls - 1 then
n = argn
--m = math.floor(n/(nlvls+1))+1
m = math.ceil(n/nlvls)
self.map.pos = n
pron = ((n-1)%nlvls) + 1
self.map:updatePos()
self.map:changeHero(worlds[m])
end
end
function menuClass:load()
self.seq = {"w","w","s","s","a","d","a","d","b","a"}
self.seq_n = 1
self.lolIJustPressedTheButtonLol = false
self.flagMenuStateLol = true
titleClass = nil
likeaboss = false
audio:playMusic("mapmusic")
local savedlol = {0,0}
if love.filesystem.exists("mappos.lua") then
local mappos = love.filesystem.read("mappos.lua")
local i = 1
for num in string.gmatch(mappos, "%d+") do
if i > 2 then
savedlol = {0,0}
break
end
savedlol[i] = tonumber(num)
i = i + 1
end
end
local savedpack = savedlol[1]
local savednumber = savedlol[2]
if savedpack == 0 then
savedpack = nil
savednumber = nil
end
m = globalpack or savedpack or 1
n = globalnumber or savednumber or 1
pron = n;
local smallnumber
if smallMode then
smallnumber = 25
else
smallnumber = 0
end
coins = 0
local lolcounterlulz = 1
coincounter = {}
for j, world in ipairs(diffs) do
local h = hs[world]
for i = 1, 7 do
if h[i] <= minLoops[world][i] and minLoops[world][i]~=99 then
coins = coins + 1
coincounter[lolcounterlulz] = true
end
lolcounterlulz = lolcounterlulz + 1
end
end
coins = coins - shopstate.cost()
self.butts = newButtList()
self.butts:add(newButt("play",80 - smallnumber*1.7,40,function()
nextLevelForEditorLol = pron
nextDiffForEditorLol = diffs[m]
if diffs[m]=="shop" then
changeState(shopstate)
else
changeState(gamestateClass)
end
end))
self.butts.list[1].keyshortcut = "(space)"
self.butts:add(newButt("options",width - 65 + smallnumber/2,40,function()
changeState(optionsState)
globalnumber = pron
globalpack=m
end))
self.butts:add(newButt("exit",60 - smallnumber,height - 40,function()
globalpack = m
globalnumber = pron
goBackToThisState = nil
changeState(titleScreen)
end))
if (not release) then
self.butts:add(newButt("beat all levels",width - 130, height - 160,function()
for i=1,#beatenlevels do
beatenlevels[i] = 1
end
self.map:updateNodes()
end))
end
require 'clock'
if width > 1600 then
self.c = newClock(centerx / 1.25,30)
else
self.c = newClock(centerx,30)
end
self.map = newMap(width,height,(m-1)*7 + n)
self.map:setS(getSlol(diffs[m],n))
self.map:update(0)
self.map:changeHero(diffs[m])
if lolNecoDirection == nil then
self.map.maphero.mirror = true
end
self.coinbutt = newButt("coins: "..coins,centerx,height - 40,function()
end)
self.coinbutt.flagNoAnimLol = true
--self.coinbutt.noborder = true
end
function menuClass:draw()
local large = false
if width > 1600 then
large = true
end
if large then
love.graphics.push()
love.graphics.scale(1.25)
end
self.map:draw(self.c)
if large then
love.graphics.pop()
end
self.butts:draw()
self.map.butt:draw()
--[[if showFPS then
love.graphics.print("fps: "..love.timer.getFPS(),width/2 - 20,height - 30)
end]]
--love.graphics.print("coins: " .. coins,width/2 - 20,height - 40)
self.coinbutt:draw()
end
function menuClass:mousepressed()
if not self.butts:click() then
self.map:click()
self.map:setS(getSlol(diffs[m],pron))--{diffs[m].." - lvl "..pron,"record: xx loops","try to get xx loops"})
end
end
function getSlol(diff,n)
local nloops = minLoops[diff][n]
local lols = " loops"
if nloops == 1 then
lols = " loop"
end
if not (diff == "shop") then
local record = hs[diff][n]
if record > nloops then
if record == 99 then
record = "none"
else
record = record .. " loops"
end
return {diff.." - lvl "..n,"record: "..record,"try to get "..nloops.. lols}
elseif record == 99 then
return {diff.." - lvl "..n,"record: none","good luck!"}
end
return {diff.." - lvl "..n,"record: "..record.." loops","coin obtained!"}
else
return {diff}
end
end
function menuClass:keypressed(k)
if (not release) and k=="e" then
globalnumber = pron
globalpack = m
changeState(editorSClass)
elseif k=="return" or k==" " then
if not self.lolIJustPressedTheButtonLol then
nextLevelForEditorLol = pron
nextDiffForEditorLol = diffs[m]
if diffs[m]=="shop" then
changeState(shopstate)
else
changeState(gamestateClass)
end
self.lolIJustPressedTheButtonLol = true
end
elseif (not release) and k == "c" then
changeState(creditsState)
elseif k == self.seq[self.seq_n] then
self.seq_n = self.seq_n + 1
if self.seq_n > #self.seq then
changeState(poemState)
end
else
self.seq_n = 1
end
end
function menuClass:update(dt)
self.c:update(dt)
self.map:update(dt)
end