Zuletzt aktiv 1734158250

state.lua Orginalformat Playground
1-- circle game --
2machine.state = {
3 ["last_key_pressed"] = "",
4 ["event_args"] = {},
5 ["dt"] = 0,
6 ["default_font"] = love.graphics.getFont(),
7 ["circles"] = {},
8 ["large_font"] = love.graphics.newFont(64),
9}
10
11-- zombie game --
12machine.state = {
13 ["player"] = {x = 400, y = 300, r = 10, health = 5},
14 ["bullets"] = {},
15 ["event_args"] = {},
16 ["spawn_timer"] = { time_left = 1, duration = 1 },
17 ["dt"] = 0,
18 ["zombies"] = {},
19}
20
21-- merged state --
22machine.state = {
23 ["circles"] = {},
24 ["last_key_pressed"] = "",
25 ["player"] = {x = 400, y = 300, r = 10, health = 5},
26 ["event_args"] = {},
27 ["bullets"] = {},
28 ["dt"] = 0,
29 ["zombies"] = {},
30 ["spawn_timer"] = { time_left = 1, duration = 1 },
31 ["default_font"] = love.graphics.getFont(),
32 ["large_font"] = love.graphics.newFont(64),
33}
zz-cicles.lua Orginalformat Playground
1local min, max, huge = math.min, math.max, math.huge
2local machine = {state = {}}
3
4machine.counters = {
5 ["@number -> @new circle x:654311463"] = 0,
6 ["@number -> @new circle x:6745479"] = 0,
7 ["@number -> @new circle x:172961"] = 0,
8 ["@number -> @new circle x:678"] = 0,
9 ["@number -> @new circle x:3"] = 0,
10 ["@number -> @new circle x:1"] = 0,
11 ["@number -> @new circle y:35322350018592"] = 0,
12 ["@number -> @new circle y:146565767712"] = 0,
13 ["generate x position"] = 0,
14 ["@number -> @new circle y:6745479"] = 0,
15 ["@number -> @new circle y:172961"] = 0,
16 ["@number -> @new circle y:678"] = 0,
17 ["@number -> @new circle y:3"] = 0,
18 ["@number -> @new circle y:1"] = 0,
19 ["generate speed"] = 0,
20 ["clear @circle index:146565767712"] = 0,
21 ["clear @circle index:654311463"] = 0,
22 ["clear @circle index:6745479"] = 0,
23 ["clear @circle index:172961"] = 0,
24 ["clear @circle index:678"] = 0,
25 ["clear @circle index:3"] = 0,
26 ["clear @circle index:1"] = 0,
27 ["clear @circle index"] = 0,
28 ["@number -> @new circle speed:146565767712"] = 0,
29 ["@number -> @new circle speed:654311463"] = 0,
30 ["@number -> @new circle speed:6745479"] = 0,
31 ["@number -> @new circle speed:172961"] = 0,
32 ["@number -> @new circle speed:678"] = 0,
33 ["@number -> @new circle speed:3"] = 0,
34 ["@number -> @new circle speed:1"] = 0,
35 ["@number -> @new circle r:35322350018592"] = 0,
36 ["@number -> @new circle r:146565767712"] = 0,
37 ["@number -> @new circle r:654311463"] = 0,
38 ["@number -> @new circle r:6745479"] = 0,
39 ["@number -> @new circle r:172961"] = 0,
40 ["@number -> @new circle x"] = 0,
41 ["@number -> @new circle r:3"] = 0,
42 ["@number -> @new circle r:1"] = 0,
43 ["@number -> @new circle y"] = 0,
44 ["@number -> @new circle r"] = 0,
45 ["@number -> @new circle speed"] = 0,
46 ["move @number to @new circle x"] = 0,
47 ["@get random number"] = 0,
48 ["@random min"] = 0,
49 ["handling input"] = 0,
50 ["run main loop"] = 1,
51 ["start polling inputs"] = 0,
52 ["@number"] = 0,
53 ["handle input"] = 0,
54 ["run current frame"] = 0,
55 ["@print fps"] = 0,
56 ["@save key pressed"] = 0,
57 ["@new circle"] = 0,
58 ["@print key pressed"] = 0,
59 ["@new circle y"] = 0,
60 ["circle count"] = 0,
61 ["@new circle r"] = 0,
62 ["iteration"] = 0,
63 ["@new circle speed"] = 0,
64 ["@event keypressed"] = 0,
65 ["@draw circle"] = 0,
66 ["make circles"] = 0,
67 ["@once"] = 1,
68 ["@move circle"] = 0,
69 ["@poll input"] = 0,
70 ["@quit love"] = 0,
71 ["make circles:100"] = 0,
72 ["@step timer"] = 0,
73 ["@event keyreleased"] = 0,
74 ["@event mousemoved"] = 0,
75 ["@clear screen"] = 0,
76 ["@present"] = 0,
77 ["@sleep"] = 0,
78 ["@ms"] = 0,
79 ["@no events left"] = 0,
80 ["@event quit"] = 0,
81 ["step timer"] = 0,
82 ["clear the screen"] = 0,
83 ["@exit code"] = 0,
84 ["draw scene"] = 0,
85 ["present current frame"] = 0,
86 ["sleep for 1ms"] = 0,
87 ["next cycle"] = 0,
88 ["clear @circle index:9007199254740991"] = 0,
89 ["@number -> @new circle x:9007199254740991"] = 0,
90 ["update scene state"] = 0,
91 ["@number -> @new circle y:9007199254740991"] = 0,
92 ["poll input"] = 0,
93 ["@number -> @new circle r:9007199254740991"] = 0,
94 ["@random max"] = 0,
95 ["@number -> @new circle speed:9007199254740991"] = 0,
96 ["make circle"] = 0,
97 ["circle count => iteration:1"] = 0,
98 ["@random min:25"] = 0,
99 ["make new circle"] = 0,
100 ["@random max:775"] = 0,
101 ["generate radius"] = 0,
102 ["generate y position"] = 0,
103 ["@random max:575"] = 0,
104 ["@start polling"] = 0,
105 ["circle count => iteration:6745479"] = 0,
106 ["@random min:1"] = 0,
107 ["circle count => iteration:654311463"] = 0,
108 ["@random max:3"] = 0,
109 ["circle count => iteration:146565767712"] = 0,
110 ["move @number to @new circle r"] = 0,
111 ["@random min:2"] = 0,
112 ["move @number to @new circle y"] = 0,
113 ["@random max:5"] = 0,
114 ["get random number"] = 0,
115 ["reset @circle index"] = 0,
116 ["circle count => iteration"] = 0,
117 ["copied circle count"] = 0,
118 ["@circle index"] = 0,
119 ["copy circle count to iteration"] = 0,
120 ["@number -> @new circle speed:35322350018592"] = 0,
121 ["clear @circle index:35322350018592"] = 0,
122 ["@event mouse pressed"] = 0,
123 ["draw each circle"] = 0,
124 ["circle count => iteration:9007199254740991"] = 0,
125 ["draw circles"] = 0,
126 ["@number -> @new circle y:654311463"] = 0,
127 ["print fps"] = 0,
128 ["@new circle x"] = 0,
129 ["print key pressed"] = 0,
130 ["@number -> @new circle r:678"] = 0,
131 ["drawing scene"] = 0,
132 ["@random max:1"] = 0,
133 ["make circles:1"] = 0,
134 ["circle count => iteration:35322350018592"] = 0,
135 ["move each circle"] = 0,
136 ["update circles"] = 0,
137 ["move @number to @new circle speed"] = 0,
138 ["updating scene"] = 0,
139 ["circle count => iteration:172961"] = 0,
140 ["circle count => iteration:678"] = 0,
141 ["circle count => iteration:3"] = 0,
142 ["spawn 100 circles"] = 0,
143 ["@number -> @new circle x:35322350018592"] = 0,
144 ["@number -> @new circle x:146565767712"] = 0,
145}
146
147machine.state = {
148 ["last_key_pressed"] = "",
149 ["event_args"] = {},
150 ["dt"] = 0,
151 ["default_font"] = love.graphics.getFont(),
152 ["circles"] = {},
153 ["large_font"] = love.graphics.newFont(64),
154}
155
156function machine:on_new_circle(counters, new_circle_x, new_circle_y, new_circle_r, new_circle_speed)
157 table.insert(self.state.circles,
158 { x = new_circle_x
159 , y = new_circle_y
160 , r = new_circle_r
161 , speed = new_circle_speed
162 , t = 0
163 }
164 )
165
166
167end
168
169function machine:on_draw_circle(counters, circle_index)
170 local circle = self.state.circles[circle_index]
171 local ox, oy = math.cos(circle.speed * circle.t + circle_index), math.sin(circle.speed * circle.t + circle_index)
172 love.graphics.circle("fill", circle.x + 5 * ox , circle.y + 5 * oy , circle.r)
173
174
175end
176
177function machine:on_move_circle(counters, circle_index)
178 local circle = self.state.circles[circle_index]
179 circle.t = circle.t + self.state.dt
180
181
182end
183
184function machine:on_get_random_number(counters, random_min, random_max)
185 counters["@number"] = math.random(random_min, random_max)
186
187
188end
189
190function machine:on_print_fps(counters)
191 love.graphics.setColor(1, 0, 0)
192 love.graphics.setFont(self.state.default_font)
193 love.graphics.print(tostring(love.timer.getFPS()), 10, 10)
194 love.graphics.setColor(1, 1, 1)
195
196
197end
198
199function machine:on_save_key_pressed(counters)
200 self.state.last_key_pressed = self.state.event_args[1]
201
202
203end
204
205function machine:on_print_key_pressed(counters)
206 love.graphics.setFont(self.state.large_font)
207 local key = self.state.last_key_pressed
208 local width, height = self.state.large_font:getWidth(key), self.state.large_font:getHeight(key)
209 love.graphics.setColor(0, 0, 0)
210 love.graphics.print(key, 400 - width / 2 + 5, 300 - height / 2 + 5)
211 love.graphics.setColor(1, 0, 0)
212 love.graphics.print(key, 400 - width / 2, 300 - height / 2)
213 love.graphics.setColor(1, 1, 1)
214
215
216end
217
218function machine:on_start_polling(counters)
219 love.event.pump()
220 self.state.event_iter = love.event.poll()
221
222
223end
224
225function machine:on_poll_input(counters)
226 local name, a, b, c, d, e, f = self.state.event_iter()
227 if name then
228 local counter = "@event " .. name
229 if counters[counter] then
230 counters[counter] = 1
231 self.state.event_args[1] = a
232 self.state.event_args[2] = b
233 self.state.event_args[3] = c
234 self.state.event_args[4] = d
235 self.state.event_args[5] = e
236 self.state.event_args[6] = f
237 end
238 else
239 counters["@no events left"] = 1
240 end
241
242
243end
244
245function machine:on_quit_love(counters)
246 counters["@exit code"] = self.state.event_args[1] or 0
247
248
249end
250
251function machine:on_step_timer(counters)
252 self.state.dt = love.timer.step()
253
254
255end
256
257function machine:on_clear_screen(counters)
258 love.graphics.origin()
259 love.graphics.clear(love.graphics.getBackgroundColor())
260
261
262end
263
264function machine:on_present(counters)
265 love.graphics.present()
266
267
268end
269
270function machine:on_sleep(counters, ms)
271 love.timer.sleep(ms / 1000)
272
273
274end
275
276function match(self, counters)
277 if counters["@new circle"] > 0 then
278 self:on_new_circle(counters, counters["@new circle x"], counters["@new circle y"], counters["@new circle r"], counters["@new circle speed"])
279 counters["@new circle"] = 0
280 counters["@new circle x"] = 0
281 counters["@new circle y"] = 0
282 counters["@new circle r"] = 0
283 counters["@new circle speed"] = 0
284 return true
285 end
286 if counters["@draw circle"] > 0 then
287 self:on_draw_circle(counters, counters["@circle index"])
288 counters["@draw circle"] = 0
289 return true
290 end
291 if counters["@move circle"] > 0 then
292 self:on_move_circle(counters, counters["@circle index"])
293 counters["@move circle"] = 0
294 return true
295 end
296 if counters["@get random number"] > 0 then
297 counters["@number"] = 0
298 self:on_get_random_number(counters, counters["@random min"], counters["@random max"])
299 counters["@get random number"] = 0
300 counters["@random min"] = 0
301 counters["@random max"] = 0
302 return true
303 end
304 if counters["@print fps"] > 0 then
305 self:on_print_fps(counters)
306 counters["@print fps"] = 0
307 return true
308 end
309 if counters["@save key pressed"] > 0 then
310 self:on_save_key_pressed(counters)
311 counters["@save key pressed"] = 0
312 return true
313 end
314 if counters["@print key pressed"] > 0 then
315 self:on_print_key_pressed(counters)
316 counters["@print key pressed"] = 0
317 return true
318 end
319 if counters["@start polling"] > 0 then
320 self:on_start_polling(counters)
321 counters["@start polling"] = 0
322 return true
323 end
324 if counters["@poll input"] > 0 then
325 counters["@event keypressed"] = 0
326 counters["@event keyreleased"] = 0
327 counters["@event mousemoved"] = 0
328 counters["@event mouse pressed"] = 0
329 counters["@no events left"] = 0
330 self:on_poll_input(counters)
331 counters["@poll input"] = 0
332 return true
333 end
334 if counters["@quit love"] > 0 then
335 counters["@exit code"] = 0
336 self:on_quit_love(counters)
337 counters["@quit love"] = 0
338 return true
339 end
340 if counters["@step timer"] > 0 then
341 self:on_step_timer(counters)
342 counters["@step timer"] = 0
343 return true
344 end
345 if counters["@clear screen"] > 0 then
346 self:on_clear_screen(counters)
347 counters["@clear screen"] = 0
348 return true
349 end
350 if counters["@present"] > 0 then
351 self:on_present(counters)
352 counters["@present"] = 0
353 return true
354 end
355 if counters["@sleep"] > 0 then
356 self:on_sleep(counters, counters["@ms"])
357 counters["@sleep"] = 0
358 counters["@ms"] = 0
359 return true
360 end
361 if counters["@random max:5"] > 0 then
362 local acc = counters["@random max:5"]
363 counters["@random max:5"] = max(counters["@random max:5"] - acc, 0)
364 counters["@random max:1"] = counters["@random max:1"] + acc * 5
365 return true
366 end
367 if counters["@random max:1"] > 0 then
368 local acc = counters["@random max:1"]
369 counters["@random max:1"] = max(counters["@random max:1"] - acc, 0)
370 counters["@random max"] = counters["@random max"] + acc * 1
371 return true
372 end
373 if counters["@random min:25"] > 0 then
374 local acc = counters["@random min:25"]
375 counters["@random min:25"] = max(counters["@random min:25"] - acc, 0)
376 counters["@random min:1"] = counters["@random min:1"] + acc * 25
377 return true
378 end
379 if counters["@random min:1"] > 0 then
380 local acc = counters["@random min:1"]
381 counters["@random min:1"] = max(counters["@random min:1"] - acc, 0)
382 counters["@random min"] = counters["@random min"] + acc * 1
383 return true
384 end
385 if counters["@random max:775"] > 0 then
386 local acc = counters["@random max:775"]
387 counters["@random max:775"] = max(counters["@random max:775"] - acc, 0)
388 counters["@random max:5"] = counters["@random max:5"] + acc * 155
389 return true
390 end
391 if counters["@random max:5"] > 0 then
392 local acc = counters["@random max:5"]
393 counters["@random max:5"] = max(counters["@random max:5"] - acc, 0)
394 counters["@random max:1"] = counters["@random max:1"] + acc * 5
395 return true
396 end
397 if counters["@random max:1"] > 0 then
398 local acc = counters["@random max:1"]
399 counters["@random max:1"] = max(counters["@random max:1"] - acc, 0)
400 counters["@random max"] = counters["@random max"] + acc * 1
401 return true
402 end
403 if counters["make circles:100"] > 0 then
404 local acc = counters["make circles:100"]
405 counters["make circles:100"] = max(counters["make circles:100"] - acc, 0)
406 counters["make circles:1"] = counters["make circles:1"] + acc * 100
407 return true
408 end
409 if counters["make circles:1"] > 0 then
410 local acc = counters["make circles:1"]
411 counters["make circles:1"] = max(counters["make circles:1"] - acc, 0)
412 counters["make circles"] = counters["make circles"] + acc * 1
413 return true
414 end
415 if counters["@random max:575"] > 0 then
416 local acc = counters["@random max:575"]
417 counters["@random max:575"] = max(counters["@random max:575"] - acc, 0)
418 counters["@random max:5"] = counters["@random max:5"] + acc * 115
419 return true
420 end
421 if counters["@random max:5"] > 0 then
422 local acc = counters["@random max:5"]
423 counters["@random max:5"] = max(counters["@random max:5"] - acc, 0)
424 counters["@random max:1"] = counters["@random max:1"] + acc * 5
425 return true
426 end
427 if counters["@random max:1"] > 0 then
428 local acc = counters["@random max:1"]
429 counters["@random max:1"] = max(counters["@random max:1"] - acc, 0)
430 counters["@random max"] = counters["@random max"] + acc * 1
431 return true
432 end
433 if counters["circle count => iteration:9007199254740991"] > 0 then
434 local acc = counters["circle count => iteration:9007199254740991"]
435 counters["circle count => iteration:9007199254740991"] = max(counters["circle count => iteration:9007199254740991"] - acc, 0)
436 counters["circle count => iteration"] = counters["circle count => iteration"] + acc * 31
437 counters["circle count => iteration:35322350018592"] = counters["circle count => iteration:35322350018592"] + acc * 255
438 return true
439 end
440 if counters["circle count => iteration:35322350018592"] > 0 then
441 local acc = counters["circle count => iteration:35322350018592"]
442 counters["circle count => iteration:35322350018592"] = max(counters["circle count => iteration:35322350018592"] - acc, 0)
443 counters["circle count => iteration:146565767712"] = counters["circle count => iteration:146565767712"] + acc * 241
444 return true
445 end
446 if counters["circle count => iteration:146565767712"] > 0 then
447 local acc = counters["circle count => iteration:146565767712"]
448 counters["circle count => iteration:146565767712"] = max(counters["circle count => iteration:146565767712"] - acc, 0)
449 counters["circle count => iteration:654311463"] = counters["circle count => iteration:654311463"] + acc * 224
450 return true
451 end
452 if counters["circle count => iteration:654311463"] > 0 then
453 local acc = counters["circle count => iteration:654311463"]
454 counters["circle count => iteration:654311463"] = max(counters["circle count => iteration:654311463"] - acc, 0)
455 counters["circle count => iteration:6745479"] = counters["circle count => iteration:6745479"] + acc * 97
456 return true
457 end
458 if counters["circle count => iteration:6745479"] > 0 then
459 local acc = counters["circle count => iteration:6745479"]
460 counters["circle count => iteration:6745479"] = max(counters["circle count => iteration:6745479"] - acc, 0)
461 counters["circle count => iteration:172961"] = counters["circle count => iteration:172961"] + acc * 39
462 return true
463 end
464 if counters["circle count => iteration:172961"] > 0 then
465 local acc = counters["circle count => iteration:172961"]
466 counters["circle count => iteration:172961"] = max(counters["circle count => iteration:172961"] - acc, 0)
467 counters["circle count => iteration"] = counters["circle count => iteration"] + acc * 71
468 counters["circle count => iteration:678"] = counters["circle count => iteration:678"] + acc * 255
469 return true
470 end
471 if counters["circle count => iteration:678"] > 0 then
472 local acc = counters["circle count => iteration:678"]
473 counters["circle count => iteration:678"] = max(counters["circle count => iteration:678"] - acc, 0)
474 counters["circle count => iteration:3"] = counters["circle count => iteration:3"] + acc * 226
475 return true
476 end
477 if counters["circle count => iteration:3"] > 0 then
478 local acc = counters["circle count => iteration:3"]
479 counters["circle count => iteration:3"] = max(counters["circle count => iteration:3"] - acc, 0)
480 counters["circle count => iteration:1"] = counters["circle count => iteration:1"] + acc * 3
481 return true
482 end
483 if counters["circle count => iteration:1"] > 0 then
484 local acc = counters["circle count => iteration:1"]
485 counters["circle count => iteration:1"] = max(counters["circle count => iteration:1"] - acc, 0)
486 counters["circle count => iteration"] = counters["circle count => iteration"] + acc * 1
487 return true
488 end
489 if counters["@number -> @new circle x:9007199254740991"] > 0 then
490 local acc = counters["@number -> @new circle x:9007199254740991"]
491 counters["@number -> @new circle x:9007199254740991"] = max(counters["@number -> @new circle x:9007199254740991"] - acc, 0)
492 counters["@number -> @new circle x:35322350018592"] = counters["@number -> @new circle x:35322350018592"] + acc * 255
493 counters["@number -> @new circle x"] = counters["@number -> @new circle x"] + acc * 31
494 return true
495 end
496 if counters["@number -> @new circle x:35322350018592"] > 0 then
497 local acc = counters["@number -> @new circle x:35322350018592"]
498 counters["@number -> @new circle x:35322350018592"] = max(counters["@number -> @new circle x:35322350018592"] - acc, 0)
499 counters["@number -> @new circle x:146565767712"] = counters["@number -> @new circle x:146565767712"] + acc * 241
500 return true
501 end
502 if counters["@number -> @new circle x:146565767712"] > 0 then
503 local acc = counters["@number -> @new circle x:146565767712"]
504 counters["@number -> @new circle x:146565767712"] = max(counters["@number -> @new circle x:146565767712"] - acc, 0)
505 counters["@number -> @new circle x:654311463"] = counters["@number -> @new circle x:654311463"] + acc * 224
506 return true
507 end
508 if counters["@number -> @new circle x:654311463"] > 0 then
509 local acc = counters["@number -> @new circle x:654311463"]
510 counters["@number -> @new circle x:654311463"] = max(counters["@number -> @new circle x:654311463"] - acc, 0)
511 counters["@number -> @new circle x:6745479"] = counters["@number -> @new circle x:6745479"] + acc * 97
512 return true
513 end
514 if counters["@number -> @new circle x:6745479"] > 0 then
515 local acc = counters["@number -> @new circle x:6745479"]
516 counters["@number -> @new circle x:6745479"] = max(counters["@number -> @new circle x:6745479"] - acc, 0)
517 counters["@number -> @new circle x:172961"] = counters["@number -> @new circle x:172961"] + acc * 39
518 return true
519 end
520 if counters["@number -> @new circle x:172961"] > 0 then
521 local acc = counters["@number -> @new circle x:172961"]
522 counters["@number -> @new circle x:172961"] = max(counters["@number -> @new circle x:172961"] - acc, 0)
523 counters["@number -> @new circle x"] = counters["@number -> @new circle x"] + acc * 71
524 counters["@number -> @new circle x:678"] = counters["@number -> @new circle x:678"] + acc * 255
525 return true
526 end
527 if counters["@number -> @new circle x:678"] > 0 then
528 local acc = counters["@number -> @new circle x:678"]
529 counters["@number -> @new circle x:678"] = max(counters["@number -> @new circle x:678"] - acc, 0)
530 counters["@number -> @new circle x:3"] = counters["@number -> @new circle x:3"] + acc * 226
531 return true
532 end
533 if counters["@number -> @new circle x:3"] > 0 then
534 local acc = counters["@number -> @new circle x:3"]
535 counters["@number -> @new circle x:3"] = max(counters["@number -> @new circle x:3"] - acc, 0)
536 counters["@number -> @new circle x:1"] = counters["@number -> @new circle x:1"] + acc * 3
537 return true
538 end
539 if counters["@number -> @new circle x:1"] > 0 then
540 local acc = counters["@number -> @new circle x:1"]
541 counters["@number -> @new circle x:1"] = max(counters["@number -> @new circle x:1"] - acc, 0)
542 counters["@number -> @new circle x"] = counters["@number -> @new circle x"] + acc * 1
543 return true
544 end
545 if counters["@random min:1"] > 0 then
546 local acc = counters["@random min:1"]
547 counters["@random min:1"] = max(counters["@random min:1"] - acc, 0)
548 counters["@random min"] = counters["@random min"] + acc * 1
549 return true
550 end
551 if counters["@number -> @new circle y:9007199254740991"] > 0 then
552 local acc = counters["@number -> @new circle y:9007199254740991"]
553 counters["@number -> @new circle y:9007199254740991"] = max(counters["@number -> @new circle y:9007199254740991"] - acc, 0)
554 counters["@number -> @new circle y:35322350018592"] = counters["@number -> @new circle y:35322350018592"] + acc * 255
555 counters["@number -> @new circle y"] = counters["@number -> @new circle y"] + acc * 31
556 return true
557 end
558 if counters["@number -> @new circle y:35322350018592"] > 0 then
559 local acc = counters["@number -> @new circle y:35322350018592"]
560 counters["@number -> @new circle y:35322350018592"] = max(counters["@number -> @new circle y:35322350018592"] - acc, 0)
561 counters["@number -> @new circle y:146565767712"] = counters["@number -> @new circle y:146565767712"] + acc * 241
562 return true
563 end
564 if counters["@number -> @new circle y:146565767712"] > 0 then
565 local acc = counters["@number -> @new circle y:146565767712"]
566 counters["@number -> @new circle y:146565767712"] = max(counters["@number -> @new circle y:146565767712"] - acc, 0)
567 counters["@number -> @new circle y:654311463"] = counters["@number -> @new circle y:654311463"] + acc * 224
568 return true
569 end
570 if counters["@number -> @new circle y:654311463"] > 0 then
571 local acc = counters["@number -> @new circle y:654311463"]
572 counters["@number -> @new circle y:654311463"] = max(counters["@number -> @new circle y:654311463"] - acc, 0)
573 counters["@number -> @new circle y:6745479"] = counters["@number -> @new circle y:6745479"] + acc * 97
574 return true
575 end
576 if counters["@number -> @new circle y:6745479"] > 0 then
577 local acc = counters["@number -> @new circle y:6745479"]
578 counters["@number -> @new circle y:6745479"] = max(counters["@number -> @new circle y:6745479"] - acc, 0)
579 counters["@number -> @new circle y:172961"] = counters["@number -> @new circle y:172961"] + acc * 39
580 return true
581 end
582 if counters["@number -> @new circle y:172961"] > 0 then
583 local acc = counters["@number -> @new circle y:172961"]
584 counters["@number -> @new circle y:172961"] = max(counters["@number -> @new circle y:172961"] - acc, 0)
585 counters["@number -> @new circle y"] = counters["@number -> @new circle y"] + acc * 71
586 counters["@number -> @new circle y:678"] = counters["@number -> @new circle y:678"] + acc * 255
587 return true
588 end
589 if counters["@number -> @new circle y:678"] > 0 then
590 local acc = counters["@number -> @new circle y:678"]
591 counters["@number -> @new circle y:678"] = max(counters["@number -> @new circle y:678"] - acc, 0)
592 counters["@number -> @new circle y:3"] = counters["@number -> @new circle y:3"] + acc * 226
593 return true
594 end
595 if counters["@number -> @new circle y:3"] > 0 then
596 local acc = counters["@number -> @new circle y:3"]
597 counters["@number -> @new circle y:3"] = max(counters["@number -> @new circle y:3"] - acc, 0)
598 counters["@number -> @new circle y:1"] = counters["@number -> @new circle y:1"] + acc * 3
599 return true
600 end
601 if counters["@number -> @new circle y:1"] > 0 then
602 local acc = counters["@number -> @new circle y:1"]
603 counters["@number -> @new circle y:1"] = max(counters["@number -> @new circle y:1"] - acc, 0)
604 counters["@number -> @new circle y"] = counters["@number -> @new circle y"] + acc * 1
605 return true
606 end
607 if counters["@random max:3"] > 0 then
608 local acc = counters["@random max:3"]
609 counters["@random max:3"] = max(counters["@random max:3"] - acc, 0)
610 counters["@random max:1"] = counters["@random max:1"] + acc * 3
611 return true
612 end
613 if counters["@random max:1"] > 0 then
614 local acc = counters["@random max:1"]
615 counters["@random max:1"] = max(counters["@random max:1"] - acc, 0)
616 counters["@random max"] = counters["@random max"] + acc * 1
617 return true
618 end
619 if counters["clear @circle index:9007199254740991"] > 0 then
620 local acc = counters["clear @circle index:9007199254740991"]
621 counters["clear @circle index:9007199254740991"] = max(counters["clear @circle index:9007199254740991"] - acc, 0)
622 counters["clear @circle index:35322350018592"] = counters["clear @circle index:35322350018592"] + acc * 255
623 counters["clear @circle index"] = counters["clear @circle index"] + acc * 31
624 return true
625 end
626 if counters["clear @circle index:35322350018592"] > 0 then
627 local acc = counters["clear @circle index:35322350018592"]
628 counters["clear @circle index:35322350018592"] = max(counters["clear @circle index:35322350018592"] - acc, 0)
629 counters["clear @circle index:146565767712"] = counters["clear @circle index:146565767712"] + acc * 241
630 return true
631 end
632 if counters["clear @circle index:146565767712"] > 0 then
633 local acc = counters["clear @circle index:146565767712"]
634 counters["clear @circle index:146565767712"] = max(counters["clear @circle index:146565767712"] - acc, 0)
635 counters["clear @circle index:654311463"] = counters["clear @circle index:654311463"] + acc * 224
636 return true
637 end
638 if counters["clear @circle index:654311463"] > 0 then
639 local acc = counters["clear @circle index:654311463"]
640 counters["clear @circle index:654311463"] = max(counters["clear @circle index:654311463"] - acc, 0)
641 counters["clear @circle index:6745479"] = counters["clear @circle index:6745479"] + acc * 97
642 return true
643 end
644 if counters["clear @circle index:6745479"] > 0 then
645 local acc = counters["clear @circle index:6745479"]
646 counters["clear @circle index:6745479"] = max(counters["clear @circle index:6745479"] - acc, 0)
647 counters["clear @circle index:172961"] = counters["clear @circle index:172961"] + acc * 39
648 return true
649 end
650 if counters["clear @circle index:172961"] > 0 then
651 local acc = counters["clear @circle index:172961"]
652 counters["clear @circle index:172961"] = max(counters["clear @circle index:172961"] - acc, 0)
653 counters["clear @circle index"] = counters["clear @circle index"] + acc * 71
654 counters["clear @circle index:678"] = counters["clear @circle index:678"] + acc * 255
655 return true
656 end
657 if counters["clear @circle index:678"] > 0 then
658 local acc = counters["clear @circle index:678"]
659 counters["clear @circle index:678"] = max(counters["clear @circle index:678"] - acc, 0)
660 counters["clear @circle index:3"] = counters["clear @circle index:3"] + acc * 226
661 return true
662 end
663 if counters["clear @circle index:3"] > 0 then
664 local acc = counters["clear @circle index:3"]
665 counters["clear @circle index:3"] = max(counters["clear @circle index:3"] - acc, 0)
666 counters["clear @circle index:1"] = counters["clear @circle index:1"] + acc * 3
667 return true
668 end
669 if counters["clear @circle index:1"] > 0 then
670 local acc = counters["clear @circle index:1"]
671 counters["clear @circle index:1"] = max(counters["clear @circle index:1"] - acc, 0)
672 counters["clear @circle index"] = counters["clear @circle index"] + acc * 1
673 return true
674 end
675 if counters["@random min:2"] > 0 then
676 local acc = counters["@random min:2"]
677 counters["@random min:2"] = max(counters["@random min:2"] - acc, 0)
678 counters["@random min:1"] = counters["@random min:1"] + acc * 2
679 return true
680 end
681 if counters["@random min:1"] > 0 then
682 local acc = counters["@random min:1"]
683 counters["@random min:1"] = max(counters["@random min:1"] - acc, 0)
684 counters["@random min"] = counters["@random min"] + acc * 1
685 return true
686 end
687 if counters["@number -> @new circle speed:9007199254740991"] > 0 then
688 local acc = counters["@number -> @new circle speed:9007199254740991"]
689 counters["@number -> @new circle speed:9007199254740991"] = max(counters["@number -> @new circle speed:9007199254740991"] - acc, 0)
690 counters["@number -> @new circle speed:35322350018592"] = counters["@number -> @new circle speed:35322350018592"] + acc * 255
691 counters["@number -> @new circle speed"] = counters["@number -> @new circle speed"] + acc * 31
692 return true
693 end
694 if counters["@number -> @new circle speed:35322350018592"] > 0 then
695 local acc = counters["@number -> @new circle speed:35322350018592"]
696 counters["@number -> @new circle speed:35322350018592"] = max(counters["@number -> @new circle speed:35322350018592"] - acc, 0)
697 counters["@number -> @new circle speed:146565767712"] = counters["@number -> @new circle speed:146565767712"] + acc * 241
698 return true
699 end
700 if counters["@number -> @new circle speed:146565767712"] > 0 then
701 local acc = counters["@number -> @new circle speed:146565767712"]
702 counters["@number -> @new circle speed:146565767712"] = max(counters["@number -> @new circle speed:146565767712"] - acc, 0)
703 counters["@number -> @new circle speed:654311463"] = counters["@number -> @new circle speed:654311463"] + acc * 224
704 return true
705 end
706 if counters["@number -> @new circle speed:654311463"] > 0 then
707 local acc = counters["@number -> @new circle speed:654311463"]
708 counters["@number -> @new circle speed:654311463"] = max(counters["@number -> @new circle speed:654311463"] - acc, 0)
709 counters["@number -> @new circle speed:6745479"] = counters["@number -> @new circle speed:6745479"] + acc * 97
710 return true
711 end
712 if counters["@number -> @new circle speed:6745479"] > 0 then
713 local acc = counters["@number -> @new circle speed:6745479"]
714 counters["@number -> @new circle speed:6745479"] = max(counters["@number -> @new circle speed:6745479"] - acc, 0)
715 counters["@number -> @new circle speed:172961"] = counters["@number -> @new circle speed:172961"] + acc * 39
716 return true
717 end
718 if counters["@number -> @new circle speed:172961"] > 0 then
719 local acc = counters["@number -> @new circle speed:172961"]
720 counters["@number -> @new circle speed:172961"] = max(counters["@number -> @new circle speed:172961"] - acc, 0)
721 counters["@number -> @new circle speed"] = counters["@number -> @new circle speed"] + acc * 71
722 counters["@number -> @new circle speed:678"] = counters["@number -> @new circle speed:678"] + acc * 255
723 return true
724 end
725 if counters["@number -> @new circle speed:678"] > 0 then
726 local acc = counters["@number -> @new circle speed:678"]
727 counters["@number -> @new circle speed:678"] = max(counters["@number -> @new circle speed:678"] - acc, 0)
728 counters["@number -> @new circle speed:3"] = counters["@number -> @new circle speed:3"] + acc * 226
729 return true
730 end
731 if counters["@number -> @new circle speed:3"] > 0 then
732 local acc = counters["@number -> @new circle speed:3"]
733 counters["@number -> @new circle speed:3"] = max(counters["@number -> @new circle speed:3"] - acc, 0)
734 counters["@number -> @new circle speed:1"] = counters["@number -> @new circle speed:1"] + acc * 3
735 return true
736 end
737 if counters["@number -> @new circle speed:1"] > 0 then
738 local acc = counters["@number -> @new circle speed:1"]
739 counters["@number -> @new circle speed:1"] = max(counters["@number -> @new circle speed:1"] - acc, 0)
740 counters["@number -> @new circle speed"] = counters["@number -> @new circle speed"] + acc * 1
741 return true
742 end
743 if counters["@number -> @new circle r:9007199254740991"] > 0 then
744 local acc = counters["@number -> @new circle r:9007199254740991"]
745 counters["@number -> @new circle r:9007199254740991"] = max(counters["@number -> @new circle r:9007199254740991"] - acc, 0)
746 counters["@number -> @new circle r:35322350018592"] = counters["@number -> @new circle r:35322350018592"] + acc * 255
747 counters["@number -> @new circle r"] = counters["@number -> @new circle r"] + acc * 31
748 return true
749 end
750 if counters["@number -> @new circle r:35322350018592"] > 0 then
751 local acc = counters["@number -> @new circle r:35322350018592"]
752 counters["@number -> @new circle r:35322350018592"] = max(counters["@number -> @new circle r:35322350018592"] - acc, 0)
753 counters["@number -> @new circle r:146565767712"] = counters["@number -> @new circle r:146565767712"] + acc * 241
754 return true
755 end
756 if counters["@number -> @new circle r:146565767712"] > 0 then
757 local acc = counters["@number -> @new circle r:146565767712"]
758 counters["@number -> @new circle r:146565767712"] = max(counters["@number -> @new circle r:146565767712"] - acc, 0)
759 counters["@number -> @new circle r:654311463"] = counters["@number -> @new circle r:654311463"] + acc * 224
760 return true
761 end
762 if counters["@number -> @new circle r:654311463"] > 0 then
763 local acc = counters["@number -> @new circle r:654311463"]
764 counters["@number -> @new circle r:654311463"] = max(counters["@number -> @new circle r:654311463"] - acc, 0)
765 counters["@number -> @new circle r:6745479"] = counters["@number -> @new circle r:6745479"] + acc * 97
766 return true
767 end
768 if counters["@number -> @new circle r:6745479"] > 0 then
769 local acc = counters["@number -> @new circle r:6745479"]
770 counters["@number -> @new circle r:6745479"] = max(counters["@number -> @new circle r:6745479"] - acc, 0)
771 counters["@number -> @new circle r:172961"] = counters["@number -> @new circle r:172961"] + acc * 39
772 return true
773 end
774 if counters["@number -> @new circle r:172961"] > 0 then
775 local acc = counters["@number -> @new circle r:172961"]
776 counters["@number -> @new circle r:172961"] = max(counters["@number -> @new circle r:172961"] - acc, 0)
777 counters["@number -> @new circle r"] = counters["@number -> @new circle r"] + acc * 71
778 counters["@number -> @new circle r:678"] = counters["@number -> @new circle r:678"] + acc * 255
779 return true
780 end
781 if counters["@number -> @new circle r:678"] > 0 then
782 local acc = counters["@number -> @new circle r:678"]
783 counters["@number -> @new circle r:678"] = max(counters["@number -> @new circle r:678"] - acc, 0)
784 counters["@number -> @new circle r:3"] = counters["@number -> @new circle r:3"] + acc * 226
785 return true
786 end
787 if counters["@number -> @new circle r:3"] > 0 then
788 local acc = counters["@number -> @new circle r:3"]
789 counters["@number -> @new circle r:3"] = max(counters["@number -> @new circle r:3"] - acc, 0)
790 counters["@number -> @new circle r:1"] = counters["@number -> @new circle r:1"] + acc * 3
791 return true
792 end
793 if counters["@number -> @new circle r:1"] > 0 then
794 local acc = counters["@number -> @new circle r:1"]
795 counters["@number -> @new circle r:1"] = max(counters["@number -> @new circle r:1"] - acc, 0)
796 counters["@number -> @new circle r"] = counters["@number -> @new circle r"] + acc * 1
797 return true
798 end
799 if counters["clear @circle index"] > 0 and counters["@circle index"] > 0 then
800 local acc = huge
801 acc = min(acc, counters["clear @circle index"])
802 acc = min(acc, counters["@circle index"])
803 counters["clear @circle index"] = max(counters["clear @circle index"] - acc, 0)
804 counters["@circle index"] = max(counters["@circle index"] - acc, 0)
805 counters["clear @circle index"] = counters["clear @circle index"] + acc * 1
806 return true
807 end
808 if counters["clear @circle index"] > 0 then
809 local acc = counters["clear @circle index"]
810 counters["clear @circle index"] = max(counters["clear @circle index"] - acc, 0)
811 return true
812 end
813 if counters["reset @circle index"] > 0 then
814 local acc = counters["reset @circle index"]
815 counters["reset @circle index"] = max(counters["reset @circle index"] - acc, 0)
816 counters["clear @circle index:9007199254740991"] = counters["clear @circle index:9007199254740991"] + acc * 1
817 return true
818 end
819 if counters["get random number"] > 0 then
820 local acc = counters["get random number"]
821 counters["get random number"] = max(counters["get random number"] - acc, 0)
822 counters["@get random number"] = counters["@get random number"] + acc * 1
823 return true
824 end
825 if counters["@number -> @new circle x"] > 0 and counters["@number"] > 0 then
826 local acc = huge
827 acc = min(acc, counters["@number"])
828 acc = min(acc, counters["@number -> @new circle x"])
829 counters["@number -> @new circle x"] = max(counters["@number -> @new circle x"] - acc, 0)
830 counters["@number"] = max(counters["@number"] - acc, 0)
831 counters["@new circle x"] = counters["@new circle x"] + acc * 1
832 counters["@number -> @new circle x"] = counters["@number -> @new circle x"] + acc * 1
833 return true
834 end
835 if counters["@number -> @new circle x"] > 0 then
836 local acc = counters["@number -> @new circle x"]
837 counters["@number -> @new circle x"] = max(counters["@number -> @new circle x"] - acc, 0)
838 return true
839 end
840 if counters["@number -> @new circle y"] > 0 and counters["@number"] > 0 then
841 local acc = huge
842 acc = min(acc, counters["@number -> @new circle y"])
843 acc = min(acc, counters["@number"])
844 counters["@number -> @new circle y"] = max(counters["@number -> @new circle y"] - acc, 0)
845 counters["@number"] = max(counters["@number"] - acc, 0)
846 counters["@number -> @new circle y"] = counters["@number -> @new circle y"] + acc * 1
847 counters["@new circle y"] = counters["@new circle y"] + acc * 1
848 return true
849 end
850 if counters["@number -> @new circle y"] > 0 then
851 local acc = counters["@number -> @new circle y"]
852 counters["@number -> @new circle y"] = max(counters["@number -> @new circle y"] - acc, 0)
853 return true
854 end
855 if counters["@number -> @new circle r"] > 0 and counters["@number"] > 0 then
856 local acc = huge
857 acc = min(acc, counters["@number"])
858 acc = min(acc, counters["@number -> @new circle r"])
859 counters["@number -> @new circle r"] = max(counters["@number -> @new circle r"] - acc, 0)
860 counters["@number"] = max(counters["@number"] - acc, 0)
861 counters["@new circle r"] = counters["@new circle r"] + acc * 1
862 counters["@number -> @new circle r"] = counters["@number -> @new circle r"] + acc * 1
863 return true
864 end
865 if counters["@number -> @new circle r"] > 0 then
866 local acc = counters["@number -> @new circle r"]
867 counters["@number -> @new circle r"] = max(counters["@number -> @new circle r"] - acc, 0)
868 return true
869 end
870 if counters["@number -> @new circle speed"] > 0 and counters["@number"] > 0 then
871 local acc = huge
872 acc = min(acc, counters["@number -> @new circle speed"])
873 acc = min(acc, counters["@number"])
874 counters["@number -> @new circle speed"] = max(counters["@number -> @new circle speed"] - acc, 0)
875 counters["@number"] = max(counters["@number"] - acc, 0)
876 counters["@number -> @new circle speed"] = counters["@number -> @new circle speed"] + acc * 1
877 counters["@new circle speed"] = counters["@new circle speed"] + acc * 1
878 return true
879 end
880 if counters["@number -> @new circle speed"] > 0 then
881 local acc = counters["@number -> @new circle speed"]
882 counters["@number -> @new circle speed"] = max(counters["@number -> @new circle speed"] - acc, 0)
883 return true
884 end
885 if counters["move @number to @new circle x"] > 0 then
886 local acc = counters["move @number to @new circle x"]
887 counters["move @number to @new circle x"] = max(counters["move @number to @new circle x"] - acc, 0)
888 counters["@number -> @new circle x:9007199254740991"] = counters["@number -> @new circle x:9007199254740991"] + acc * 1
889 return true
890 end
891 if counters["move @number to @new circle y"] > 0 then
892 local acc = counters["move @number to @new circle y"]
893 counters["move @number to @new circle y"] = max(counters["move @number to @new circle y"] - acc, 0)
894 counters["@number -> @new circle y:9007199254740991"] = counters["@number -> @new circle y:9007199254740991"] + acc * 1
895 return true
896 end
897 if counters["move @number to @new circle r"] > 0 then
898 local acc = counters["move @number to @new circle r"]
899 counters["move @number to @new circle r"] = max(counters["move @number to @new circle r"] - acc, 0)
900 counters["@number -> @new circle r:9007199254740991"] = counters["@number -> @new circle r:9007199254740991"] + acc * 1
901 return true
902 end
903 if counters["move @number to @new circle speed"] > 0 then
904 local acc = counters["move @number to @new circle speed"]
905 counters["move @number to @new circle speed"] = max(counters["move @number to @new circle speed"] - acc, 0)
906 counters["@number -> @new circle speed:9007199254740991"] = counters["@number -> @new circle speed:9007199254740991"] + acc * 1
907 return true
908 end
909 if counters["generate x position"] > 0 then
910 local acc = counters["generate x position"]
911 counters["generate x position"] = max(counters["generate x position"] - acc, 0)
912 counters["move @number to @new circle x"] = counters["move @number to @new circle x"] + acc * 1
913 counters["@random min:25"] = counters["@random min:25"] + acc * 1
914 counters["@random max:775"] = counters["@random max:775"] + acc * 1
915 counters["get random number"] = counters["get random number"] + acc * 1
916 return true
917 end
918 if counters["generate y position"] > 0 then
919 local acc = counters["generate y position"]
920 counters["generate y position"] = max(counters["generate y position"] - acc, 0)
921 counters["move @number to @new circle y"] = counters["move @number to @new circle y"] + acc * 1
922 counters["@random min:25"] = counters["@random min:25"] + acc * 1
923 counters["@random max:575"] = counters["@random max:575"] + acc * 1
924 counters["get random number"] = counters["get random number"] + acc * 1
925 return true
926 end
927 if counters["generate radius"] > 0 then
928 local acc = counters["generate radius"]
929 counters["generate radius"] = max(counters["generate radius"] - acc, 0)
930 counters["move @number to @new circle r"] = counters["move @number to @new circle r"] + acc * 1
931 counters["@random min:1"] = counters["@random min:1"] + acc * 1
932 counters["@random max:3"] = counters["@random max:3"] + acc * 1
933 counters["get random number"] = counters["get random number"] + acc * 1
934 return true
935 end
936 if counters["generate speed"] > 0 then
937 local acc = counters["generate speed"]
938 counters["generate speed"] = max(counters["generate speed"] - acc, 0)
939 counters["@random max:5"] = counters["@random max:5"] + acc * 1
940 counters["move @number to @new circle speed"] = counters["move @number to @new circle speed"] + acc * 1
941 counters["@random min:2"] = counters["@random min:2"] + acc * 1
942 counters["get random number"] = counters["get random number"] + acc * 1
943 return true
944 end
945 if counters["make new circle"] > 0 then
946 local acc = counters["make new circle"]
947 counters["make new circle"] = max(counters["make new circle"] - acc, 0)
948 counters["@new circle"] = counters["@new circle"] + acc * 1
949 return true
950 end
951 if counters["make circle"] > 0 then
952 local acc = counters["make circle"]
953 counters["make circle"] = max(counters["make circle"] - acc, 0)
954 counters["generate x position"] = counters["generate x position"] + acc * 1
955 counters["generate y position"] = counters["generate y position"] + acc * 1
956 counters["generate radius"] = counters["generate radius"] + acc * 1
957 counters["generate speed"] = counters["generate speed"] + acc * 1
958 counters["make new circle"] = counters["make new circle"] + acc * 1
959 return true
960 end
961 if counters["circle count => iteration"] > 0 and counters["circle count"] > 0 then
962 local acc = huge
963 acc = min(acc, counters["circle count"])
964 acc = min(acc, counters["circle count => iteration"])
965 counters["circle count => iteration"] = max(counters["circle count => iteration"] - acc, 0)
966 counters["circle count"] = max(counters["circle count"] - acc, 0)
967 counters["iteration"] = counters["iteration"] + acc * 1
968 counters["copied circle count"] = counters["copied circle count"] + acc * 1
969 return true
970 end
971 if counters["circle count => iteration"] > 0 then
972 local acc = counters["circle count => iteration"]
973 counters["circle count => iteration"] = max(counters["circle count => iteration"] - acc, 0)
974 return true
975 end
976 if counters["copied circle count"] > 0 then
977 local acc = counters["copied circle count"]
978 counters["copied circle count"] = max(counters["copied circle count"] - acc, 0)
979 counters["circle count"] = counters["circle count"] + acc * 1
980 return true
981 end
982 if counters["copy circle count to iteration"] > 0 then
983 local acc = counters["copy circle count to iteration"]
984 counters["copy circle count to iteration"] = max(counters["copy circle count to iteration"] - acc, 0)
985 counters["circle count => iteration:9007199254740991"] = counters["circle count => iteration:9007199254740991"] + acc * 1
986 return true
987 end
988 if counters["draw each circle"] > 0 and counters["iteration"] > 0 then
989 local acc = huge
990 acc = min(acc, counters["draw each circle"])
991 acc = min(acc, counters["iteration"])
992 counters["draw each circle"] = max(counters["draw each circle"] - acc, 0)
993 counters["iteration"] = max(counters["iteration"] - acc, 0)
994 counters["@draw circle"] = counters["@draw circle"] + acc * 1
995 counters["draw each circle"] = counters["draw each circle"] + acc * 1
996 counters["@circle index"] = counters["@circle index"] + acc * 1
997 return true
998 end
999 if counters["draw each circle"] > 0 then
1000 local acc = counters["draw each circle"]
1001 counters["draw each circle"] = max(counters["draw each circle"] - acc, 0)
1002 return true
1003 end
1004 if counters["draw circles"] > 0 then
1005 local acc = counters["draw circles"]
1006 counters["draw circles"] = max(counters["draw circles"] - acc, 0)
1007 counters["draw each circle"] = counters["draw each circle"] + acc * 1
1008 counters["copy circle count to iteration"] = counters["copy circle count to iteration"] + acc * 1
1009 counters["reset @circle index"] = counters["reset @circle index"] + acc * 1
1010 return true
1011 end
1012 if counters["print fps"] > 0 then
1013 local acc = counters["print fps"]
1014 counters["print fps"] = max(counters["print fps"] - acc, 0)
1015 counters["@print fps"] = counters["@print fps"] + acc * 1
1016 return true
1017 end
1018 if counters["print key pressed"] > 0 then
1019 local acc = counters["print key pressed"]
1020 counters["print key pressed"] = max(counters["print key pressed"] - acc, 0)
1021 counters["@print key pressed"] = counters["@print key pressed"] + acc * 1
1022 return true
1023 end
1024 if counters["drawing scene"] > 0 then
1025 local acc = counters["drawing scene"]
1026 counters["drawing scene"] = max(counters["drawing scene"] - acc, 0)
1027 counters["draw circles"] = counters["draw circles"] + acc * 1
1028 counters["print fps"] = counters["print fps"] + acc * 1
1029 counters["print key pressed"] = counters["print key pressed"] + acc * 1
1030 return true
1031 end
1032 if counters["move each circle"] > 0 and counters["iteration"] > 0 then
1033 local acc = huge
1034 acc = min(acc, counters["move each circle"])
1035 acc = min(acc, counters["iteration"])
1036 counters["move each circle"] = max(counters["move each circle"] - acc, 0)
1037 counters["iteration"] = max(counters["iteration"] - acc, 0)
1038 counters["@move circle"] = counters["@move circle"] + acc * 1
1039 counters["move each circle"] = counters["move each circle"] + acc * 1
1040 counters["@circle index"] = counters["@circle index"] + acc * 1
1041 return true
1042 end
1043 if counters["move each circle"] > 0 then
1044 local acc = counters["move each circle"]
1045 counters["move each circle"] = max(counters["move each circle"] - acc, 0)
1046 return true
1047 end
1048 if counters["update circles"] > 0 then
1049 local acc = counters["update circles"]
1050 counters["update circles"] = max(counters["update circles"] - acc, 0)
1051 counters["move each circle"] = counters["move each circle"] + acc * 1
1052 counters["copy circle count to iteration"] = counters["copy circle count to iteration"] + acc * 1
1053 counters["reset @circle index"] = counters["reset @circle index"] + acc * 1
1054 return true
1055 end
1056 if counters["updating scene"] > 0 then
1057 local acc = counters["updating scene"]
1058 counters["updating scene"] = max(counters["updating scene"] - acc, 0)
1059 counters["update circles"] = counters["update circles"] + acc * 1
1060 return true
1061 end
1062 if counters["handling input"] > 0 and counters["@event keypressed"] > 0 then
1063 local acc = huge
1064 acc = min(acc, counters["@event keypressed"])
1065 acc = min(acc, counters["handling input"])
1066 counters["handling input"] = max(counters["handling input"] - acc, 0)
1067 counters["@event keypressed"] = max(counters["@event keypressed"] - acc, 0)
1068 counters["@save key pressed"] = counters["@save key pressed"] + acc * 1
1069 counters["spawn 100 circles"] = counters["spawn 100 circles"] + acc * 1
1070 return true
1071 end
1072 if counters["spawn 100 circles"] > 0 then
1073 local acc = counters["spawn 100 circles"]
1074 counters["spawn 100 circles"] = max(counters["spawn 100 circles"] - acc, 0)
1075 counters["make circles:100"] = counters["make circles:100"] + acc * 1
1076 return true
1077 end
1078 if counters["make circles"] > 0 and counters["@once"] > 0 then
1079 local acc = huge
1080 acc = min(acc, counters["@once"])
1081 acc = min(acc, counters["make circles"])
1082 counters["make circles"] = max(counters["make circles"] - acc, 0)
1083 counters["@once"] = max(counters["@once"] - acc, 0)
1084 counters["circle count"] = counters["circle count"] + acc * 1
1085 counters["@once"] = counters["@once"] + acc * 1
1086 counters["make circle"] = counters["make circle"] + acc * 1
1087 return true
1088 end
1089 if counters["make circles"] > 0 and counters["@once"] > 0 then
1090 local acc = huge
1091 acc = min(acc, counters["@once"])
1092 acc = min(acc, counters["make circles"])
1093 counters["make circles"] = max(counters["make circles"] - acc, 0)
1094 counters["@once"] = max(counters["@once"] - acc, 0)
1095 return true
1096 end
1097 if counters["handling input"] > 0 then
1098 local acc = counters["handling input"]
1099 counters["handling input"] = max(counters["handling input"] - acc, 0)
1100 return true
1101 end
1102 if counters["updating scene"] > 0 then
1103 local acc = counters["updating scene"]
1104 counters["updating scene"] = max(counters["updating scene"] - acc, 0)
1105 return true
1106 end
1107 if counters["drawing scene"] > 0 then
1108 local acc = counters["drawing scene"]
1109 counters["drawing scene"] = max(counters["drawing scene"] - acc, 0)
1110 return true
1111 end
1112 if counters["run main loop"] > 0 then
1113 local acc = counters["run main loop"]
1114 counters["run main loop"] = max(counters["run main loop"] - acc, 0)
1115 counters["handle input"] = counters["handle input"] + acc * 1
1116 counters["poll input"] = counters["poll input"] + acc * 1
1117 counters["run current frame"] = counters["run current frame"] + acc * 1
1118 counters["start polling inputs"] = counters["start polling inputs"] + acc * 1
1119 return true
1120 end
1121 if counters["start polling inputs"] > 0 then
1122 local acc = counters["start polling inputs"]
1123 counters["start polling inputs"] = max(counters["start polling inputs"] - acc, 0)
1124 counters["@start polling"] = counters["@start polling"] + acc * 1
1125 return true
1126 end
1127 if counters["poll input"] > 0 then
1128 local acc = counters["poll input"]
1129 counters["poll input"] = max(counters["poll input"] - acc, 0)
1130 counters["@poll input"] = counters["@poll input"] + acc * 1
1131 return true
1132 end
1133 if counters["handle input"] > 0 and counters["@no events left"] > 0 then
1134 local acc = huge
1135 acc = min(acc, counters["handle input"])
1136 acc = min(acc, counters["@no events left"])
1137 counters["handle input"] = max(counters["handle input"] - acc, 0)
1138 counters["@no events left"] = max(counters["@no events left"] - acc, 0)
1139 return true
1140 end
1141 if counters["handle input"] > 0 then
1142 local acc = counters["handle input"]
1143 counters["handle input"] = max(counters["handle input"] - acc, 0)
1144 counters["handle input"] = counters["handle input"] + acc * 1
1145 counters["poll input"] = counters["poll input"] + acc * 1
1146 counters["handling input"] = counters["handling input"] + acc * 1
1147 return true
1148 end
1149 if counters["run current frame"] > 0 and counters["@event quit"] > 0 then
1150 local acc = huge
1151 acc = min(acc, counters["run current frame"])
1152 acc = min(acc, counters["@event quit"])
1153 counters["run current frame"] = max(counters["run current frame"] - acc, 0)
1154 counters["@event quit"] = max(counters["@event quit"] - acc, 0)
1155 counters["@quit love"] = counters["@quit love"] + acc * 1
1156 return true
1157 end
1158 if counters["run current frame"] > 0 then
1159 local acc = counters["run current frame"]
1160 counters["run current frame"] = max(counters["run current frame"] - acc, 0)
1161 counters["draw scene"] = counters["draw scene"] + acc * 1
1162 counters["present current frame"] = counters["present current frame"] + acc * 1
1163 counters["sleep for 1ms"] = counters["sleep for 1ms"] + acc * 1
1164 counters["step timer"] = counters["step timer"] + acc * 1
1165 counters["clear the screen"] = counters["clear the screen"] + acc * 1
1166 counters["next cycle"] = counters["next cycle"] + acc * 1
1167 counters["update scene state"] = counters["update scene state"] + acc * 1
1168 return true
1169 end
1170 if counters["step timer"] > 0 then
1171 local acc = counters["step timer"]
1172 counters["step timer"] = max(counters["step timer"] - acc, 0)
1173 counters["@step timer"] = counters["@step timer"] + acc * 1
1174 return true
1175 end
1176 if counters["clear the screen"] > 0 then
1177 local acc = counters["clear the screen"]
1178 counters["clear the screen"] = max(counters["clear the screen"] - acc, 0)
1179 counters["@clear screen"] = counters["@clear screen"] + acc * 1
1180 return true
1181 end
1182 if counters["update scene state"] > 0 then
1183 local acc = counters["update scene state"]
1184 counters["update scene state"] = max(counters["update scene state"] - acc, 0)
1185 counters["updating scene"] = counters["updating scene"] + acc * 1
1186 return true
1187 end
1188 if counters["draw scene"] > 0 then
1189 local acc = counters["draw scene"]
1190 counters["draw scene"] = max(counters["draw scene"] - acc, 0)
1191 counters["drawing scene"] = counters["drawing scene"] + acc * 1
1192 return true
1193 end
1194 if counters["present current frame"] > 0 then
1195 local acc = counters["present current frame"]
1196 counters["present current frame"] = max(counters["present current frame"] - acc, 0)
1197 counters["@present"] = counters["@present"] + acc * 1
1198 return true
1199 end
1200 if counters["sleep for 1ms"] > 0 then
1201 local acc = counters["sleep for 1ms"]
1202 counters["sleep for 1ms"] = max(counters["sleep for 1ms"] - acc, 0)
1203 counters["@ms"] = counters["@ms"] + acc * 1
1204 return true
1205 end
1206 if counters["next cycle"] > 0 then
1207 local acc = counters["next cycle"]
1208 counters["next cycle"] = max(counters["next cycle"] - acc, 0)
1209 counters["run main loop"] = counters["run main loop"] + acc * 1
1210 return true
1211 end
1212 return false
1213end
1214
1215function machine:run()
1216 local counters = self.counters
1217 while match(self, counters) do end
1218end
1219
1220return machine
zz-zombies-and-circles.lua Orginalformat Playground
1local min, max, huge = math.min, math.max, math.huge
2local machine = {state = {}}
3
4machine.counters = {
5 ["@is [move up] down?"] = 0,
6 ["@clear screen"] = 0,
7 ["@present"] = 0,
8 ["@is [move left] down?"] = 0,
9 ["@sleep"] = 0,
10 ["@ms"] = 0,
11 ["@is [move down] down?"] = 0,
12 ["clear @circle index"] = 0,
13 ["@is [move right] down?"] = 0,
14 ["@event quit"] = 0,
15 ["@shoot bullet"] = 0,
16 ["clear the screen"] = 0,
17 ["circle count => iteration"] = 0,
18 ["copied circle count"] = 0,
19 ["get random number"] = 0,
20 ["copy circle count to iteration"] = 0,
21 ["next cycle"] = 0,
22 ["@number -> @new circle x"] = 0,
23 ["draw each circle"] = 0,
24 ["draw circles"] = 0,
25 ["@number -> @new circle y"] = 0,
26 ["print fps"] = 0,
27 ["@delete out of bounds bullets"] = 0,
28 ["@number -> @new circle r"] = 0,
29 ["@number -> @new circle speed"] = 0,
30 ["@number -> @new circle x:9007199254740991"] = 0,
31 ["move each circle"] = 0,
32 ["@number -> @new circle y:9007199254740991"] = 0,
33 ["@number -> @new circle r:9007199254740991"] = 0,
34 ["@draw bullets"] = 0,
35 ["@number -> @new circle speed:9007199254740991"] = 0,
36 ["generate x position"] = 0,
37 ["@random min:25"] = 0,
38 ["@update spawn timer"] = 0,
39 ["@random max:775"] = 0,
40 ["generate radius"] = 0,
41 ["updating scene"] = 0,
42 ["@make the timer faster"] = 0,
43 ["@random min:1"] = 0,
44 ["clear @circle index:9007199254740991"] = 0,
45 ["@random max:3"] = 0,
46 ["@random min:2"] = 0,
47 ["@random max:5"] = 0,
48 ["circle count => iteration:9007199254740991"] = 0,
49 ["@exit code"] = 0,
50 ["make circles:100"] = 0,
51 ["@do player collisions"] = 0,
52 ["sleep for 1ms"] = 0,
53 ["present current frame"] = 0,
54 ["draw scene"] = 0,
55 ["@event keyreleased"] = 0,
56 ["@event keypressed"] = 0,
57 ["@event mousemoved"] = 0,
58 ["update scene state"] = 0,
59 ["step timer"] = 0,
60 ["@event mousepressed"] = 0,
61 ["run current frame"] = 0,
62 ["handle input"] = 0,
63 ["poll input"] = 0,
64 ["start polling inputs"] = 0,
65 ["run main loop"] = 1,
66 ["reset timer"] = 0,
67 ["make the timer faster"] = 0,
68 ["@new circle"] = 0,
69 ["spawn a zombie"] = 0,
70 ["draw zombies"] = 0,
71 ["@new circle x"] = 0,
72 ["handling input"] = 0,
73 ["@new circle y"] = 0,
74 ["reset @circle index"] = 0,
75 ["@new circle r"] = 0,
76 ["update circles"] = 0,
77 ["@new circle speed"] = 0,
78 ["move player"] = 0,
79 ["iteration"] = 0,
80 ["circle count"] = 0,
81 ["make circle"] = 0,
82 ["make new circle"] = 0,
83 ["generate speed"] = 0,
84 ["generate y position"] = 0,
85 ["move @number to @new circle speed"] = 0,
86 ["move @number to @new circle r"] = 0,
87 ["@draw circle"] = 0,
88 ["move @number to @new circle y"] = 0,
89 ["move @number to @new circle x"] = 0,
90 ["moving player"] = 0,
91 ["@circle index"] = 0,
92 ["move bullets"] = 0,
93 ["handling inputs"] = 0,
94 ["move zombies"] = 0,
95 ["shoot bullet"] = 0,
96 ["check for collisions"] = 0,
97 ["spawn 100 circles"] = 0,
98 ["check for player hit by zombie"] = 0,
99 ["@move circle"] = 0,
100 ["check for bullet hitting zombie"] = 0,
101 ["draw bullets"] = 0,
102 ["update spawn timer"] = 0,
103 ["draw player"] = 0,
104 ["@spawn timer expired"] = 0,
105 ["@get random number"] = 0,
106 ["@number -> @new circle x:35322350018592"] = 0,
107 ["@number -> @new circle x:146565767712"] = 0,
108 ["@number -> @new circle x:654311463"] = 0,
109 ["@number -> @new circle x:6745479"] = 0,
110 ["@number -> @new circle x:172961"] = 0,
111 ["@number -> @new circle x:678"] = 0,
112 ["@number -> @new circle x:3"] = 0,
113 ["@number -> @new circle x:1"] = 0,
114 ["@number -> @new circle y:35322350018592"] = 0,
115 ["@number"] = 0,
116 ["@number -> @new circle y:654311463"] = 0,
117 ["@draw zombies"] = 0,
118 ["print key pressed"] = 0,
119 ["@number -> @new circle y:172961"] = 0,
120 ["@number -> @new circle y:678"] = 0,
121 ["@number -> @new circle y:3"] = 0,
122 ["@spawn a zombie"] = 0,
123 ["@random max:1"] = 0,
124 ["@number -> @new circle r:35322350018592"] = 0,
125 ["@number -> @new circle r:146565767712"] = 0,
126 ["@number -> @new circle r:654311463"] = 0,
127 ["@number -> @new circle r:6745479"] = 0,
128 ["@number -> @new circle r:172961"] = 0,
129 ["@number -> @new circle r:678"] = 0,
130 ["@number -> @new circle r:3"] = 0,
131 ["@number -> @new circle r:1"] = 0,
132 ["@number -> @new circle speed:35322350018592"] = 0,
133 ["@number -> @new circle speed:146565767712"] = 0,
134 ["@number -> @new circle speed:654311463"] = 0,
135 ["@number -> @new circle speed:6745479"] = 0,
136 ["@number -> @new circle speed:172961"] = 0,
137 ["@number -> @new circle speed:678"] = 0,
138 ["@number -> @new circle speed:3"] = 0,
139 ["@number -> @new circle speed:1"] = 0,
140 ["make circles:1"] = 0,
141 ["circle count => iteration:35322350018592"] = 0,
142 ["circle count => iteration:146565767712"] = 0,
143 ["circle count => iteration:654311463"] = 0,
144 ["circle count => iteration:6745479"] = 0,
145 ["circle count => iteration:172961"] = 0,
146 ["circle count => iteration:678"] = 0,
147 ["circle count => iteration:3"] = 0,
148 ["circle count => iteration:1"] = 0,
149 ["clear @circle index:35322350018592"] = 0,
150 ["clear @circle index:146565767712"] = 0,
151 ["clear @circle index:654311463"] = 0,
152 ["clear @circle index:6745479"] = 0,
153 ["clear @circle index:172961"] = 0,
154 ["clear @circle index:678"] = 0,
155 ["clear @circle index:3"] = 0,
156 ["clear @circle index:1"] = 0,
157 ["drawing scene"] = 0,
158 ["make circles"] = 0,
159 ["sweep deleted entities"] = 0,
160 ["@once"] = 1,
161 ["@no events left"] = 0,
162 ["@[move up] is down"] = 0,
163 ["@print key pressed"] = 0,
164 ["@random min"] = 0,
165 ["@[move down] is down"] = 0,
166 ["@random max"] = 0,
167 ["@number -> @new circle y:1"] = 0,
168 ["@number -> @new circle y:6745479"] = 0,
169 ["@start polling"] = 0,
170 ["@reset timer"] = 0,
171 ["@move bullets"] = 0,
172 ["@draw player"] = 0,
173 ["@do bullet collisions"] = 0,
174 ["@move zombies"] = 0,
175 ["@number -> @new circle y:146565767712"] = 0,
176 ["@poll input"] = 0,
177 ["@move player"] = 0,
178 ["@[move right] is down"] = 0,
179 ["@dir up"] = 0,
180 ["@[move left] is down"] = 0,
181 ["@dir down"] = 0,
182 ["@quit love"] = 0,
183 ["@dir left"] = 0,
184 ["@save key pressed"] = 0,
185 ["@dir right"] = 0,
186 ["@print fps"] = 0,
187 ["@delete killed zombies"] = 0,
188 ["@step timer"] = 0,
189 ["@random max:575"] = 0,
190}
191
192machine.state = {
193 ["circles"] = {},
194 ["last_key_pressed"] = "",
195 ["player"] = {x = 400, y = 300, r = 10, health = 5},
196 ["event_args"] = {},
197 ["bullets"] = {},
198 ["dt"] = 0,
199 ["zombies"] = {},
200 ["spawn_timer"] = { time_left = 1, duration = 1 },
201 ["default_font"] = love.graphics.getFont(),
202 ["large_font"] = love.graphics.newFont(64),
203}
204
205function machine:on_new_circle(counters, new_circle_x, new_circle_y, new_circle_r, new_circle_speed)
206 table.insert(self.state.circles,
207 { x = new_circle_x
208 , y = new_circle_y
209 , r = new_circle_r
210 , speed = new_circle_speed
211 , t = 0
212 }
213 )
214
215
216end
217
218function machine:on_draw_circle(counters, circle_index)
219 local circle = self.state.circles[circle_index]
220 local ox, oy = math.cos(circle.speed * circle.t + circle_index), math.sin(circle.speed * circle.t + circle_index)
221 love.graphics.circle("fill", circle.x + 5 * ox , circle.y + 5 * oy , circle.r)
222
223
224end
225
226function machine:on_move_circle(counters, circle_index)
227 local circle = self.state.circles[circle_index]
228 circle.t = circle.t + self.state.dt
229
230
231end
232
233function machine:on_get_random_number(counters, random_min, random_max)
234 counters["@number"] = math.random(random_min, random_max)
235
236
237end
238
239function machine:on_print_fps(counters)
240 love.graphics.setColor(1, 0, 0)
241 love.graphics.print(
242 tostring(love.timer.getFPS())
243 .. " bullets: " .. tostring(#self.state.bullets)
244 .. " zombies: " .. tostring(#self.state.zombies)
245 , 10, 10)
246 love.graphics.setColor(1, 1, 1)
247
248
249end
250
251function machine:on_save_key_pressed(counters)
252 self.state.last_key_pressed = self.state.event_args[1]
253
254
255end
256
257function machine:on_print_key_pressed(counters)
258 love.graphics.setFont(self.state.large_font)
259 local key = self.state.last_key_pressed
260 local width, height = self.state.large_font:getWidth(key), self.state.large_font:getHeight(key)
261 love.graphics.setColor(0, 0, 0)
262 love.graphics.print(key, 400 - width / 2 + 5, 300 - height / 2 + 5)
263 love.graphics.setColor(1, 0, 0)
264 love.graphics.print(key, 400 - width / 2, 300 - height / 2)
265 love.graphics.setColor(1, 1, 1)
266
267
268end
269
270function machine:on_print_fps(counters)
271 love.graphics.setColor(1, 0, 0)
272 love.graphics.print(
273 tostring(love.timer.getFPS())
274 .. " bullets: " .. tostring(#self.state.bullets)
275 .. " zombies: " .. tostring(#self.state.zombies)
276 , 10, 10)
277 love.graphics.setColor(1, 1, 1)
278
279
280end
281
282function machine:on_draw_player(counters)
283 local player = self.state.player
284 love.graphics.setColor(0, 1, 0)
285 love.graphics.circle("fill", player.x, player.y, player.r)
286 love.graphics.setColor(1, 1, 1)
287
288
289end
290
291function machine:on_move_player(counters, dir_up, dir_down, dir_left, dir_right)
292 local player = self.state.player
293 local dir_y = (dir_down - dir_up)
294 local dir_x = (dir_right - dir_left)
295 player.x = player.x + dir_x * self.state.dt * 300
296 player.y = player.y + dir_y * self.state.dt * 300
297
298
299end
300
301function machine:on_is_move_up_down(counters)
302 if love.keyboard.isDown("w") then
303 counters["@[move up] is down"] = 1
304 end
305
306
307end
308
309function machine:on_is_move_left_down(counters)
310 if love.keyboard.isDown("a") then
311 counters["@[move left] is down"] = 1
312 end
313
314
315end
316
317function machine:on_is_move_down_down(counters)
318 if love.keyboard.isDown("s") then
319 counters["@[move down] is down"] = 1
320 end
321
322
323end
324
325function machine:on_is_move_right_down(counters)
326 if love.keyboard.isDown("d") then
327 counters["@[move right] is down"] = 1
328 end
329
330
331end
332
333function machine:on_shoot_bullet(counters)
334 local bullets = self.state.bullets
335 local px, py = self.state.player.x, self.state.player.y
336 local mx, my = love.mouse.getPosition()
337 local angle = math.atan2(my - py, mx - px)
338 table.insert(bullets, {x = px, y = py, angle = angle, r = 5})
339
340
341end
342
343function machine:on_move_bullets(counters)
344 local dt = self.state.dt
345 local bullets = self.state.bullets
346 for _, bullet in ipairs(bullets) do
347 bullet.x = bullet.x + math.cos(bullet.angle) * 350 * dt
348 bullet.y = bullet.y + math.sin(bullet.angle) * 350 * dt
349 local in_bounds
350 = -10 <= bullet.x and bullet.x <= 810
351 and -10 <= bullet.y and bullet.y <= 610
352 if not in_bounds then
353 bullet.deleted = true
354 end
355 end
356
357
358end
359
360function machine:on_delete_bullets(counters)
361 local bullets = self.state.bullets
362 local survivers = {}
363 for _, bullet in ipairs(bullets) do
364 if not bullet.deleted then
365 table.insert(survivers, bullet)
366 end
367 end
368 self.state.bullets = survivers
369
370
371end
372
373function machine:on_draw_bullets(counters)
374 local bullets = self.state.bullets
375 for _, bullet in ipairs(bullets) do
376 love.graphics.setColor(1, 1, 0)
377 love.graphics.circle("fill", bullet.x, bullet.y, bullet.r)
378 love.graphics.setColor(1, 1, 1)
379 end
380
381
382end
383
384function machine:on_update_spawn_timer(counters)
385 local spawn_timer = self.state.spawn_timer
386 spawn_timer.time_left = spawn_timer.time_left - self.state.dt
387 if 0 >= spawn_timer.time_left then
388 counters["@spawn timer expired"] = 1
389 end
390
391
392end
393
394function machine:on_make_the_timer_faster(counters)
395 local spawn_timer = self.state.spawn_timer
396 spawn_timer.duration = spawn_timer.duration - 0.0125
397
398
399end
400
401function machine:on_reset_timer(counters)
402 local spawn_timer = self.state.spawn_timer
403 spawn_timer.time_left = spawn_timer.duration
404
405
406end
407
408function machine:on_draw_zombies(counters)
409 local zombies = self.state.zombies
410 for _, zombie in ipairs(zombies) do
411 love.graphics.setColor(1, 0, 0)
412 love.graphics.circle("fill", zombie.x, zombie.y, zombie.r)
413 love.graphics.setColor(1, 0, 0)
414 end
415
416
417end
418
419function machine:on_spawn_a_zombie(counters)
420 local angle = math.random() * math.pi * 2
421 local x, y = math.cos(angle) * 450 + 400, math.sin(angle) * 350 + 300
422 table.insert(self.state.zombies, {x = x, y = y, health = 2, r = 10})
423
424
425end
426
427function machine:on_delete_killed_zombies(counters)
428 local zombies = self.state.zombies
429 local survivers = {}
430 for _, zombie in ipairs(zombies) do
431 if not zombie.dead then
432 table.insert(survivers, zombie)
433 end
434 end
435 self.state.zombies = survivers
436
437
438end
439
440function machine:on_move_zombies(counters)
441 local player = self.state.player
442 local zombies = self.state.zombies
443 for _, zombie in ipairs(zombies) do
444 local angle = math.atan2(player.y - zombie.y, player.x - zombie.x)
445 zombie.x = zombie.x + self.state.dt * math.cos(angle) * 310
446 zombie.y = zombie.y + self.state.dt * math.sin(angle) * 310
447 end
448
449
450end
451
452function machine:on_do_bullet_collisions(counters)
453 local bullets = self.state.bullets
454 local zombies = self.state.zombies
455
456 for _, bullet in ipairs(bullets) do
457 if bullet.deleted then goto next_bullet end
458 for _, zombie in ipairs(zombies) do
459 if zombie.dead then goto next_zombie end
460 local min_distance = bullet.r + zombie.r
461 local distance = math.sqrt((bullet.x - zombie.x) ^ 2 + (bullet.y - zombie.y) ^ 2)
462 if distance < min_distance then
463 zombie.health = zombie.health - 1
464 if zombie.health < 0 then
465 zombie.dead = true
466 end
467 bullet.deleted = true
468 end
469 ::next_zombie::
470 end
471 ::next_bullet::
472 end
473
474
475
476
477end
478
479function machine:on_start_polling(counters)
480 love.event.pump()
481 self.state.event_iter = love.event.poll()
482
483
484end
485
486function machine:on_poll_input(counters)
487 local name, a, b, c, d, e, f = self.state.event_iter()
488 if name then
489 local counter = "@event " .. name
490 if counters[counter] then
491 counters[counter] = 1
492 self.state.event_args[1] = a
493 self.state.event_args[2] = b
494 self.state.event_args[3] = c
495 self.state.event_args[4] = d
496 self.state.event_args[5] = e
497 self.state.event_args[6] = f
498 end
499 else
500 counters["@no events left"] = 1
501 end
502
503
504end
505
506function machine:on_quit_love(counters)
507 counters["@exit code"] = self.state.event_args[1] or 0
508
509
510end
511
512function machine:on_step_timer(counters)
513 self.state.dt = love.timer.step()
514
515
516end
517
518function machine:on_clear_screen(counters)
519 love.graphics.origin()
520 love.graphics.clear(love.graphics.getBackgroundColor())
521
522
523end
524
525function machine:on_present(counters)
526 love.graphics.present()
527
528
529end
530
531function machine:on_sleep(counters, ms)
532 love.timer.sleep(ms / 1000)
533
534
535end
536
537function match(self, counters)
538 if counters["@new circle"] > 0 then
539 self:on_new_circle(counters, counters["@new circle x"], counters["@new circle y"], counters["@new circle r"], counters["@new circle speed"])
540 counters["@new circle"] = 0
541 counters["@new circle x"] = 0
542 counters["@new circle y"] = 0
543 counters["@new circle r"] = 0
544 counters["@new circle speed"] = 0
545 return true
546 end
547 if counters["@draw circle"] > 0 then
548 self:on_draw_circle(counters, counters["@circle index"])
549 counters["@draw circle"] = 0
550 return true
551 end
552 if counters["@move circle"] > 0 then
553 self:on_move_circle(counters, counters["@circle index"])
554 counters["@move circle"] = 0
555 return true
556 end
557 if counters["@get random number"] > 0 then
558 counters["@number"] = 0
559 self:on_get_random_number(counters, counters["@random min"], counters["@random max"])
560 counters["@get random number"] = 0
561 counters["@random min"] = 0
562 counters["@random max"] = 0
563 return true
564 end
565 if counters["@print fps"] > 0 then
566 self:on_print_fps(counters)
567 counters["@print fps"] = 0
568 return true
569 end
570 if counters["@save key pressed"] > 0 then
571 self:on_save_key_pressed(counters)
572 counters["@save key pressed"] = 0
573 return true
574 end
575 if counters["@print key pressed"] > 0 then
576 self:on_print_key_pressed(counters)
577 counters["@print key pressed"] = 0
578 return true
579 end
580 if counters["@print fps"] > 0 then
581 self:on_print_fps(counters)
582 counters["@print fps"] = 0
583 return true
584 end
585 if counters["@draw player"] > 0 then
586 self:on_draw_player(counters)
587 counters["@draw player"] = 0
588 return true
589 end
590 if counters["@move player"] > 0 then
591 self:on_move_player(counters, counters["@dir up"], counters["@dir down"], counters["@dir left"], counters["@dir right"])
592 counters["@move player"] = 0
593 counters["@dir up"] = 0
594 counters["@dir down"] = 0
595 counters["@dir left"] = 0
596 counters["@dir right"] = 0
597 return true
598 end
599 if counters["@is [move up] down?"] > 0 then
600 counters["@[move up] is down"] = 0
601 self:on_is_move_up_down(counters)
602 counters["@is [move up] down?"] = 0
603 return true
604 end
605 if counters["@is [move left] down?"] > 0 then
606 counters["@[move left] is down"] = 0
607 self:on_is_move_left_down(counters)
608 counters["@is [move left] down?"] = 0
609 return true
610 end
611 if counters["@is [move down] down?"] > 0 then
612 counters["@[move down] is down"] = 0
613 self:on_is_move_down_down(counters)
614 counters["@is [move down] down?"] = 0
615 return true
616 end
617 if counters["@is [move right] down?"] > 0 then
618 counters["@[move right] is down"] = 0
619 self:on_is_move_right_down(counters)
620 counters["@is [move right] down?"] = 0
621 return true
622 end
623 if counters["@shoot bullet"] > 0 then
624 self:on_shoot_bullet(counters)
625 counters["@shoot bullet"] = 0
626 return true
627 end
628 if counters["@move bullets"] > 0 then
629 self:on_move_bullets(counters)
630 counters["@move bullets"] = 0
631 return true
632 end
633 if counters["@delete out of bounds bullets"] > 0 then
634 self:on_delete_bullets(counters)
635 counters["@delete out of bounds bullets"] = 0
636 return true
637 end
638 if counters["@draw bullets"] > 0 then
639 self:on_draw_bullets(counters)
640 counters["@draw bullets"] = 0
641 return true
642 end
643 if counters["@update spawn timer"] > 0 then
644 counters["@spawn timer expired"] = 0
645 self:on_update_spawn_timer(counters)
646 counters["@update spawn timer"] = 0
647 return true
648 end
649 if counters["@make the timer faster"] > 0 then
650 self:on_make_the_timer_faster(counters)
651 counters["@make the timer faster"] = 0
652 return true
653 end
654 if counters["@reset timer"] > 0 then
655 self:on_reset_timer(counters)
656 counters["@reset timer"] = 0
657 return true
658 end
659 if counters["@draw zombies"] > 0 then
660 self:on_draw_zombies(counters)
661 counters["@draw zombies"] = 0
662 return true
663 end
664 if counters["@spawn a zombie"] > 0 then
665 self:on_spawn_a_zombie(counters)
666 counters["@spawn a zombie"] = 0
667 return true
668 end
669 if counters["@delete killed zombies"] > 0 then
670 self:on_delete_killed_zombies(counters)
671 counters["@delete killed zombies"] = 0
672 return true
673 end
674 if counters["@move zombies"] > 0 then
675 self:on_move_zombies(counters)
676 counters["@move zombies"] = 0
677 return true
678 end
679 if counters["@do bullet collisions"] > 0 then
680 self:on_do_bullet_collisions(counters)
681 counters["@do bullet collisions"] = 0
682 return true
683 end
684 if counters["@start polling"] > 0 then
685 self:on_start_polling(counters)
686 counters["@start polling"] = 0
687 return true
688 end
689 if counters["@poll input"] > 0 then
690 counters["@event keypressed"] = 0
691 counters["@event keyreleased"] = 0
692 counters["@event mousemoved"] = 0
693 counters["@event mousepressed"] = 0
694 counters["@no events left"] = 0
695 self:on_poll_input(counters)
696 counters["@poll input"] = 0
697 return true
698 end
699 if counters["@quit love"] > 0 then
700 counters["@exit code"] = 0
701 self:on_quit_love(counters)
702 counters["@quit love"] = 0
703 return true
704 end
705 if counters["@step timer"] > 0 then
706 self:on_step_timer(counters)
707 counters["@step timer"] = 0
708 return true
709 end
710 if counters["@clear screen"] > 0 then
711 self:on_clear_screen(counters)
712 counters["@clear screen"] = 0
713 return true
714 end
715 if counters["@present"] > 0 then
716 self:on_present(counters)
717 counters["@present"] = 0
718 return true
719 end
720 if counters["@sleep"] > 0 then
721 self:on_sleep(counters, counters["@ms"])
722 counters["@sleep"] = 0
723 counters["@ms"] = 0
724 return true
725 end
726 if counters["@number -> @new circle x:9007199254740991"] > 0 then
727 local acc = counters["@number -> @new circle x:9007199254740991"]
728 counters["@number -> @new circle x:9007199254740991"] = max(counters["@number -> @new circle x:9007199254740991"] - acc, 0)
729 counters["@number -> @new circle x:35322350018592"] = counters["@number -> @new circle x:35322350018592"] + acc * 255
730 counters["@number -> @new circle x"] = counters["@number -> @new circle x"] + acc * 31
731 return true
732 end
733 if counters["@number -> @new circle x:35322350018592"] > 0 then
734 local acc = counters["@number -> @new circle x:35322350018592"]
735 counters["@number -> @new circle x:35322350018592"] = max(counters["@number -> @new circle x:35322350018592"] - acc, 0)
736 counters["@number -> @new circle x:146565767712"] = counters["@number -> @new circle x:146565767712"] + acc * 241
737 return true
738 end
739 if counters["@number -> @new circle x:146565767712"] > 0 then
740 local acc = counters["@number -> @new circle x:146565767712"]
741 counters["@number -> @new circle x:146565767712"] = max(counters["@number -> @new circle x:146565767712"] - acc, 0)
742 counters["@number -> @new circle x:654311463"] = counters["@number -> @new circle x:654311463"] + acc * 224
743 return true
744 end
745 if counters["@number -> @new circle x:654311463"] > 0 then
746 local acc = counters["@number -> @new circle x:654311463"]
747 counters["@number -> @new circle x:654311463"] = max(counters["@number -> @new circle x:654311463"] - acc, 0)
748 counters["@number -> @new circle x:6745479"] = counters["@number -> @new circle x:6745479"] + acc * 97
749 return true
750 end
751 if counters["@number -> @new circle x:6745479"] > 0 then
752 local acc = counters["@number -> @new circle x:6745479"]
753 counters["@number -> @new circle x:6745479"] = max(counters["@number -> @new circle x:6745479"] - acc, 0)
754 counters["@number -> @new circle x:172961"] = counters["@number -> @new circle x:172961"] + acc * 39
755 return true
756 end
757 if counters["@number -> @new circle x:172961"] > 0 then
758 local acc = counters["@number -> @new circle x:172961"]
759 counters["@number -> @new circle x:172961"] = max(counters["@number -> @new circle x:172961"] - acc, 0)
760 counters["@number -> @new circle x"] = counters["@number -> @new circle x"] + acc * 71
761 counters["@number -> @new circle x:678"] = counters["@number -> @new circle x:678"] + acc * 255
762 return true
763 end
764 if counters["@number -> @new circle x:678"] > 0 then
765 local acc = counters["@number -> @new circle x:678"]
766 counters["@number -> @new circle x:678"] = max(counters["@number -> @new circle x:678"] - acc, 0)
767 counters["@number -> @new circle x:3"] = counters["@number -> @new circle x:3"] + acc * 226
768 return true
769 end
770 if counters["@number -> @new circle x:3"] > 0 then
771 local acc = counters["@number -> @new circle x:3"]
772 counters["@number -> @new circle x:3"] = max(counters["@number -> @new circle x:3"] - acc, 0)
773 counters["@number -> @new circle x:1"] = counters["@number -> @new circle x:1"] + acc * 3
774 return true
775 end
776 if counters["@number -> @new circle x:1"] > 0 then
777 local acc = counters["@number -> @new circle x:1"]
778 counters["@number -> @new circle x:1"] = max(counters["@number -> @new circle x:1"] - acc, 0)
779 counters["@number -> @new circle x"] = counters["@number -> @new circle x"] + acc * 1
780 return true
781 end
782 if counters["@random min:1"] > 0 then
783 local acc = counters["@random min:1"]
784 counters["@random min:1"] = max(counters["@random min:1"] - acc, 0)
785 counters["@random min"] = counters["@random min"] + acc * 1
786 return true
787 end
788 if counters["@number -> @new circle y:9007199254740991"] > 0 then
789 local acc = counters["@number -> @new circle y:9007199254740991"]
790 counters["@number -> @new circle y:9007199254740991"] = max(counters["@number -> @new circle y:9007199254740991"] - acc, 0)
791 counters["@number -> @new circle y:35322350018592"] = counters["@number -> @new circle y:35322350018592"] + acc * 255
792 counters["@number -> @new circle y"] = counters["@number -> @new circle y"] + acc * 31
793 return true
794 end
795 if counters["@number -> @new circle y:35322350018592"] > 0 then
796 local acc = counters["@number -> @new circle y:35322350018592"]
797 counters["@number -> @new circle y:35322350018592"] = max(counters["@number -> @new circle y:35322350018592"] - acc, 0)
798 counters["@number -> @new circle y:146565767712"] = counters["@number -> @new circle y:146565767712"] + acc * 241
799 return true
800 end
801 if counters["@number -> @new circle y:146565767712"] > 0 then
802 local acc = counters["@number -> @new circle y:146565767712"]
803 counters["@number -> @new circle y:146565767712"] = max(counters["@number -> @new circle y:146565767712"] - acc, 0)
804 counters["@number -> @new circle y:654311463"] = counters["@number -> @new circle y:654311463"] + acc * 224
805 return true
806 end
807 if counters["@number -> @new circle y:654311463"] > 0 then
808 local acc = counters["@number -> @new circle y:654311463"]
809 counters["@number -> @new circle y:654311463"] = max(counters["@number -> @new circle y:654311463"] - acc, 0)
810 counters["@number -> @new circle y:6745479"] = counters["@number -> @new circle y:6745479"] + acc * 97
811 return true
812 end
813 if counters["@number -> @new circle y:6745479"] > 0 then
814 local acc = counters["@number -> @new circle y:6745479"]
815 counters["@number -> @new circle y:6745479"] = max(counters["@number -> @new circle y:6745479"] - acc, 0)
816 counters["@number -> @new circle y:172961"] = counters["@number -> @new circle y:172961"] + acc * 39
817 return true
818 end
819 if counters["@number -> @new circle y:172961"] > 0 then
820 local acc = counters["@number -> @new circle y:172961"]
821 counters["@number -> @new circle y:172961"] = max(counters["@number -> @new circle y:172961"] - acc, 0)
822 counters["@number -> @new circle y:678"] = counters["@number -> @new circle y:678"] + acc * 255
823 counters["@number -> @new circle y"] = counters["@number -> @new circle y"] + acc * 71
824 return true
825 end
826 if counters["@number -> @new circle y:678"] > 0 then
827 local acc = counters["@number -> @new circle y:678"]
828 counters["@number -> @new circle y:678"] = max(counters["@number -> @new circle y:678"] - acc, 0)
829 counters["@number -> @new circle y:3"] = counters["@number -> @new circle y:3"] + acc * 226
830 return true
831 end
832 if counters["@number -> @new circle y:3"] > 0 then
833 local acc = counters["@number -> @new circle y:3"]
834 counters["@number -> @new circle y:3"] = max(counters["@number -> @new circle y:3"] - acc, 0)
835 counters["@number -> @new circle y:1"] = counters["@number -> @new circle y:1"] + acc * 3
836 return true
837 end
838 if counters["@number -> @new circle y:1"] > 0 then
839 local acc = counters["@number -> @new circle y:1"]
840 counters["@number -> @new circle y:1"] = max(counters["@number -> @new circle y:1"] - acc, 0)
841 counters["@number -> @new circle y"] = counters["@number -> @new circle y"] + acc * 1
842 return true
843 end
844 if counters["@random max:3"] > 0 then
845 local acc = counters["@random max:3"]
846 counters["@random max:3"] = max(counters["@random max:3"] - acc, 0)
847 counters["@random max:1"] = counters["@random max:1"] + acc * 3
848 return true
849 end
850 if counters["@random max:1"] > 0 then
851 local acc = counters["@random max:1"]
852 counters["@random max:1"] = max(counters["@random max:1"] - acc, 0)
853 counters["@random max"] = counters["@random max"] + acc * 1
854 return true
855 end
856 if counters["@number -> @new circle r:9007199254740991"] > 0 then
857 local acc = counters["@number -> @new circle r:9007199254740991"]
858 counters["@number -> @new circle r:9007199254740991"] = max(counters["@number -> @new circle r:9007199254740991"] - acc, 0)
859 counters["@number -> @new circle r:35322350018592"] = counters["@number -> @new circle r:35322350018592"] + acc * 255
860 counters["@number -> @new circle r"] = counters["@number -> @new circle r"] + acc * 31
861 return true
862 end
863 if counters["@number -> @new circle r:35322350018592"] > 0 then
864 local acc = counters["@number -> @new circle r:35322350018592"]
865 counters["@number -> @new circle r:35322350018592"] = max(counters["@number -> @new circle r:35322350018592"] - acc, 0)
866 counters["@number -> @new circle r:146565767712"] = counters["@number -> @new circle r:146565767712"] + acc * 241
867 return true
868 end
869 if counters["@number -> @new circle r:146565767712"] > 0 then
870 local acc = counters["@number -> @new circle r:146565767712"]
871 counters["@number -> @new circle r:146565767712"] = max(counters["@number -> @new circle r:146565767712"] - acc, 0)
872 counters["@number -> @new circle r:654311463"] = counters["@number -> @new circle r:654311463"] + acc * 224
873 return true
874 end
875 if counters["@number -> @new circle r:654311463"] > 0 then
876 local acc = counters["@number -> @new circle r:654311463"]
877 counters["@number -> @new circle r:654311463"] = max(counters["@number -> @new circle r:654311463"] - acc, 0)
878 counters["@number -> @new circle r:6745479"] = counters["@number -> @new circle r:6745479"] + acc * 97
879 return true
880 end
881 if counters["@number -> @new circle r:6745479"] > 0 then
882 local acc = counters["@number -> @new circle r:6745479"]
883 counters["@number -> @new circle r:6745479"] = max(counters["@number -> @new circle r:6745479"] - acc, 0)
884 counters["@number -> @new circle r:172961"] = counters["@number -> @new circle r:172961"] + acc * 39
885 return true
886 end
887 if counters["@number -> @new circle r:172961"] > 0 then
888 local acc = counters["@number -> @new circle r:172961"]
889 counters["@number -> @new circle r:172961"] = max(counters["@number -> @new circle r:172961"] - acc, 0)
890 counters["@number -> @new circle r"] = counters["@number -> @new circle r"] + acc * 71
891 counters["@number -> @new circle r:678"] = counters["@number -> @new circle r:678"] + acc * 255
892 return true
893 end
894 if counters["@number -> @new circle r:678"] > 0 then
895 local acc = counters["@number -> @new circle r:678"]
896 counters["@number -> @new circle r:678"] = max(counters["@number -> @new circle r:678"] - acc, 0)
897 counters["@number -> @new circle r:3"] = counters["@number -> @new circle r:3"] + acc * 226
898 return true
899 end
900 if counters["@number -> @new circle r:3"] > 0 then
901 local acc = counters["@number -> @new circle r:3"]
902 counters["@number -> @new circle r:3"] = max(counters["@number -> @new circle r:3"] - acc, 0)
903 counters["@number -> @new circle r:1"] = counters["@number -> @new circle r:1"] + acc * 3
904 return true
905 end
906 if counters["@number -> @new circle r:1"] > 0 then
907 local acc = counters["@number -> @new circle r:1"]
908 counters["@number -> @new circle r:1"] = max(counters["@number -> @new circle r:1"] - acc, 0)
909 counters["@number -> @new circle r"] = counters["@number -> @new circle r"] + acc * 1
910 return true
911 end
912 if counters["@number -> @new circle speed:9007199254740991"] > 0 then
913 local acc = counters["@number -> @new circle speed:9007199254740991"]
914 counters["@number -> @new circle speed:9007199254740991"] = max(counters["@number -> @new circle speed:9007199254740991"] - acc, 0)
915 counters["@number -> @new circle speed:35322350018592"] = counters["@number -> @new circle speed:35322350018592"] + acc * 255
916 counters["@number -> @new circle speed"] = counters["@number -> @new circle speed"] + acc * 31
917 return true
918 end
919 if counters["@number -> @new circle speed:35322350018592"] > 0 then
920 local acc = counters["@number -> @new circle speed:35322350018592"]
921 counters["@number -> @new circle speed:35322350018592"] = max(counters["@number -> @new circle speed:35322350018592"] - acc, 0)
922 counters["@number -> @new circle speed:146565767712"] = counters["@number -> @new circle speed:146565767712"] + acc * 241
923 return true
924 end
925 if counters["@number -> @new circle speed:146565767712"] > 0 then
926 local acc = counters["@number -> @new circle speed:146565767712"]
927 counters["@number -> @new circle speed:146565767712"] = max(counters["@number -> @new circle speed:146565767712"] - acc, 0)
928 counters["@number -> @new circle speed:654311463"] = counters["@number -> @new circle speed:654311463"] + acc * 224
929 return true
930 end
931 if counters["@number -> @new circle speed:654311463"] > 0 then
932 local acc = counters["@number -> @new circle speed:654311463"]
933 counters["@number -> @new circle speed:654311463"] = max(counters["@number -> @new circle speed:654311463"] - acc, 0)
934 counters["@number -> @new circle speed:6745479"] = counters["@number -> @new circle speed:6745479"] + acc * 97
935 return true
936 end
937 if counters["@number -> @new circle speed:6745479"] > 0 then
938 local acc = counters["@number -> @new circle speed:6745479"]
939 counters["@number -> @new circle speed:6745479"] = max(counters["@number -> @new circle speed:6745479"] - acc, 0)
940 counters["@number -> @new circle speed:172961"] = counters["@number -> @new circle speed:172961"] + acc * 39
941 return true
942 end
943 if counters["@number -> @new circle speed:172961"] > 0 then
944 local acc = counters["@number -> @new circle speed:172961"]
945 counters["@number -> @new circle speed:172961"] = max(counters["@number -> @new circle speed:172961"] - acc, 0)
946 counters["@number -> @new circle speed"] = counters["@number -> @new circle speed"] + acc * 71
947 counters["@number -> @new circle speed:678"] = counters["@number -> @new circle speed:678"] + acc * 255
948 return true
949 end
950 if counters["@number -> @new circle speed:678"] > 0 then
951 local acc = counters["@number -> @new circle speed:678"]
952 counters["@number -> @new circle speed:678"] = max(counters["@number -> @new circle speed:678"] - acc, 0)
953 counters["@number -> @new circle speed:3"] = counters["@number -> @new circle speed:3"] + acc * 226
954 return true
955 end
956 if counters["@number -> @new circle speed:3"] > 0 then
957 local acc = counters["@number -> @new circle speed:3"]
958 counters["@number -> @new circle speed:3"] = max(counters["@number -> @new circle speed:3"] - acc, 0)
959 counters["@number -> @new circle speed:1"] = counters["@number -> @new circle speed:1"] + acc * 3
960 return true
961 end
962 if counters["@number -> @new circle speed:1"] > 0 then
963 local acc = counters["@number -> @new circle speed:1"]
964 counters["@number -> @new circle speed:1"] = max(counters["@number -> @new circle speed:1"] - acc, 0)
965 counters["@number -> @new circle speed"] = counters["@number -> @new circle speed"] + acc * 1
966 return true
967 end
968 if counters["make circles:100"] > 0 then
969 local acc = counters["make circles:100"]
970 counters["make circles:100"] = max(counters["make circles:100"] - acc, 0)
971 counters["make circles:1"] = counters["make circles:1"] + acc * 100
972 return true
973 end
974 if counters["make circles:1"] > 0 then
975 local acc = counters["make circles:1"]
976 counters["make circles:1"] = max(counters["make circles:1"] - acc, 0)
977 counters["make circles"] = counters["make circles"] + acc * 1
978 return true
979 end
980 if counters["@random max:5"] > 0 then
981 local acc = counters["@random max:5"]
982 counters["@random max:5"] = max(counters["@random max:5"] - acc, 0)
983 counters["@random max:1"] = counters["@random max:1"] + acc * 5
984 return true
985 end
986 if counters["@random max:1"] > 0 then
987 local acc = counters["@random max:1"]
988 counters["@random max:1"] = max(counters["@random max:1"] - acc, 0)
989 counters["@random max"] = counters["@random max"] + acc * 1
990 return true
991 end
992 if counters["@random min:25"] > 0 then
993 local acc = counters["@random min:25"]
994 counters["@random min:25"] = max(counters["@random min:25"] - acc, 0)
995 counters["@random min:1"] = counters["@random min:1"] + acc * 25
996 return true
997 end
998 if counters["@random min:1"] > 0 then
999 local acc = counters["@random min:1"]
1000 counters["@random min:1"] = max(counters["@random min:1"] - acc, 0)
1001 counters["@random min"] = counters["@random min"] + acc * 1
1002 return true
1003 end
1004 if counters["circle count => iteration:9007199254740991"] > 0 then
1005 local acc = counters["circle count => iteration:9007199254740991"]
1006 counters["circle count => iteration:9007199254740991"] = max(counters["circle count => iteration:9007199254740991"] - acc, 0)
1007 counters["circle count => iteration"] = counters["circle count => iteration"] + acc * 31
1008 counters["circle count => iteration:35322350018592"] = counters["circle count => iteration:35322350018592"] + acc * 255
1009 return true
1010 end
1011 if counters["circle count => iteration:35322350018592"] > 0 then
1012 local acc = counters["circle count => iteration:35322350018592"]
1013 counters["circle count => iteration:35322350018592"] = max(counters["circle count => iteration:35322350018592"] - acc, 0)
1014 counters["circle count => iteration:146565767712"] = counters["circle count => iteration:146565767712"] + acc * 241
1015 return true
1016 end
1017 if counters["circle count => iteration:146565767712"] > 0 then
1018 local acc = counters["circle count => iteration:146565767712"]
1019 counters["circle count => iteration:146565767712"] = max(counters["circle count => iteration:146565767712"] - acc, 0)
1020 counters["circle count => iteration:654311463"] = counters["circle count => iteration:654311463"] + acc * 224
1021 return true
1022 end
1023 if counters["circle count => iteration:654311463"] > 0 then
1024 local acc = counters["circle count => iteration:654311463"]
1025 counters["circle count => iteration:654311463"] = max(counters["circle count => iteration:654311463"] - acc, 0)
1026 counters["circle count => iteration:6745479"] = counters["circle count => iteration:6745479"] + acc * 97
1027 return true
1028 end
1029 if counters["circle count => iteration:6745479"] > 0 then
1030 local acc = counters["circle count => iteration:6745479"]
1031 counters["circle count => iteration:6745479"] = max(counters["circle count => iteration:6745479"] - acc, 0)
1032 counters["circle count => iteration:172961"] = counters["circle count => iteration:172961"] + acc * 39
1033 return true
1034 end
1035 if counters["circle count => iteration:172961"] > 0 then
1036 local acc = counters["circle count => iteration:172961"]
1037 counters["circle count => iteration:172961"] = max(counters["circle count => iteration:172961"] - acc, 0)
1038 counters["circle count => iteration:678"] = counters["circle count => iteration:678"] + acc * 255
1039 counters["circle count => iteration"] = counters["circle count => iteration"] + acc * 71
1040 return true
1041 end
1042 if counters["circle count => iteration:678"] > 0 then
1043 local acc = counters["circle count => iteration:678"]
1044 counters["circle count => iteration:678"] = max(counters["circle count => iteration:678"] - acc, 0)
1045 counters["circle count => iteration:3"] = counters["circle count => iteration:3"] + acc * 226
1046 return true
1047 end
1048 if counters["circle count => iteration:3"] > 0 then
1049 local acc = counters["circle count => iteration:3"]
1050 counters["circle count => iteration:3"] = max(counters["circle count => iteration:3"] - acc, 0)
1051 counters["circle count => iteration:1"] = counters["circle count => iteration:1"] + acc * 3
1052 return true
1053 end
1054 if counters["circle count => iteration:1"] > 0 then
1055 local acc = counters["circle count => iteration:1"]
1056 counters["circle count => iteration:1"] = max(counters["circle count => iteration:1"] - acc, 0)
1057 counters["circle count => iteration"] = counters["circle count => iteration"] + acc * 1
1058 return true
1059 end
1060 if counters["@random max:775"] > 0 then
1061 local acc = counters["@random max:775"]
1062 counters["@random max:775"] = max(counters["@random max:775"] - acc, 0)
1063 counters["@random max:5"] = counters["@random max:5"] + acc * 155
1064 return true
1065 end
1066 if counters["@random max:5"] > 0 then
1067 local acc = counters["@random max:5"]
1068 counters["@random max:5"] = max(counters["@random max:5"] - acc, 0)
1069 counters["@random max:1"] = counters["@random max:1"] + acc * 5
1070 return true
1071 end
1072 if counters["@random max:1"] > 0 then
1073 local acc = counters["@random max:1"]
1074 counters["@random max:1"] = max(counters["@random max:1"] - acc, 0)
1075 counters["@random max"] = counters["@random max"] + acc * 1
1076 return true
1077 end
1078 if counters["@random min:2"] > 0 then
1079 local acc = counters["@random min:2"]
1080 counters["@random min:2"] = max(counters["@random min:2"] - acc, 0)
1081 counters["@random min:1"] = counters["@random min:1"] + acc * 2
1082 return true
1083 end
1084 if counters["@random min:1"] > 0 then
1085 local acc = counters["@random min:1"]
1086 counters["@random min:1"] = max(counters["@random min:1"] - acc, 0)
1087 counters["@random min"] = counters["@random min"] + acc * 1
1088 return true
1089 end
1090 if counters["clear @circle index:9007199254740991"] > 0 then
1091 local acc = counters["clear @circle index:9007199254740991"]
1092 counters["clear @circle index:9007199254740991"] = max(counters["clear @circle index:9007199254740991"] - acc, 0)
1093 counters["clear @circle index"] = counters["clear @circle index"] + acc * 31
1094 counters["clear @circle index:35322350018592"] = counters["clear @circle index:35322350018592"] + acc * 255
1095 return true
1096 end
1097 if counters["clear @circle index:35322350018592"] > 0 then
1098 local acc = counters["clear @circle index:35322350018592"]
1099 counters["clear @circle index:35322350018592"] = max(counters["clear @circle index:35322350018592"] - acc, 0)
1100 counters["clear @circle index:146565767712"] = counters["clear @circle index:146565767712"] + acc * 241
1101 return true
1102 end
1103 if counters["clear @circle index:146565767712"] > 0 then
1104 local acc = counters["clear @circle index:146565767712"]
1105 counters["clear @circle index:146565767712"] = max(counters["clear @circle index:146565767712"] - acc, 0)
1106 counters["clear @circle index:654311463"] = counters["clear @circle index:654311463"] + acc * 224
1107 return true
1108 end
1109 if counters["clear @circle index:654311463"] > 0 then
1110 local acc = counters["clear @circle index:654311463"]
1111 counters["clear @circle index:654311463"] = max(counters["clear @circle index:654311463"] - acc, 0)
1112 counters["clear @circle index:6745479"] = counters["clear @circle index:6745479"] + acc * 97
1113 return true
1114 end
1115 if counters["clear @circle index:6745479"] > 0 then
1116 local acc = counters["clear @circle index:6745479"]
1117 counters["clear @circle index:6745479"] = max(counters["clear @circle index:6745479"] - acc, 0)
1118 counters["clear @circle index:172961"] = counters["clear @circle index:172961"] + acc * 39
1119 return true
1120 end
1121 if counters["clear @circle index:172961"] > 0 then
1122 local acc = counters["clear @circle index:172961"]
1123 counters["clear @circle index:172961"] = max(counters["clear @circle index:172961"] - acc, 0)
1124 counters["clear @circle index:678"] = counters["clear @circle index:678"] + acc * 255
1125 counters["clear @circle index"] = counters["clear @circle index"] + acc * 71
1126 return true
1127 end
1128 if counters["clear @circle index:678"] > 0 then
1129 local acc = counters["clear @circle index:678"]
1130 counters["clear @circle index:678"] = max(counters["clear @circle index:678"] - acc, 0)
1131 counters["clear @circle index:3"] = counters["clear @circle index:3"] + acc * 226
1132 return true
1133 end
1134 if counters["clear @circle index:3"] > 0 then
1135 local acc = counters["clear @circle index:3"]
1136 counters["clear @circle index:3"] = max(counters["clear @circle index:3"] - acc, 0)
1137 counters["clear @circle index:1"] = counters["clear @circle index:1"] + acc * 3
1138 return true
1139 end
1140 if counters["clear @circle index:1"] > 0 then
1141 local acc = counters["clear @circle index:1"]
1142 counters["clear @circle index:1"] = max(counters["clear @circle index:1"] - acc, 0)
1143 counters["clear @circle index"] = counters["clear @circle index"] + acc * 1
1144 return true
1145 end
1146 if counters["@random max:575"] > 0 then
1147 local acc = counters["@random max:575"]
1148 counters["@random max:575"] = max(counters["@random max:575"] - acc, 0)
1149 counters["@random max:5"] = counters["@random max:5"] + acc * 115
1150 return true
1151 end
1152 if counters["@random max:5"] > 0 then
1153 local acc = counters["@random max:5"]
1154 counters["@random max:5"] = max(counters["@random max:5"] - acc, 0)
1155 counters["@random max:1"] = counters["@random max:1"] + acc * 5
1156 return true
1157 end
1158 if counters["@random max:1"] > 0 then
1159 local acc = counters["@random max:1"]
1160 counters["@random max:1"] = max(counters["@random max:1"] - acc, 0)
1161 counters["@random max"] = counters["@random max"] + acc * 1
1162 return true
1163 end
1164 if counters["updating scene"] > 0 then
1165 local acc = counters["updating scene"]
1166 counters["updating scene"] = max(counters["updating scene"] - acc, 0)
1167 counters["move player"] = counters["move player"] + acc * 1
1168 counters["check for collisions"] = counters["check for collisions"] + acc * 1
1169 counters["update circles"] = counters["update circles"] + acc * 1
1170 counters["sweep deleted entities"] = counters["sweep deleted entities"] + acc * 1
1171 counters["update spawn timer"] = counters["update spawn timer"] + acc * 1
1172 counters["move bullets"] = counters["move bullets"] + acc * 1
1173 counters["move zombies"] = counters["move zombies"] + acc * 1
1174 return true
1175 end
1176 if counters["drawing scene"] > 0 then
1177 local acc = counters["drawing scene"]
1178 counters["drawing scene"] = max(counters["drawing scene"] - acc, 0)
1179 counters["draw player"] = counters["draw player"] + acc * 1
1180 counters["print fps"] = counters["print fps"] + acc * 1
1181 counters["draw zombies"] = counters["draw zombies"] + acc * 1
1182 counters["print key pressed"] = counters["print key pressed"] + acc * 1
1183 counters["draw bullets"] = counters["draw bullets"] + acc * 1
1184 counters["draw circles"] = counters["draw circles"] + acc * 1
1185 return true
1186 end
1187 if counters["handling input"] > 0 and counters["@event keypressed"] > 0 then
1188 local acc = huge
1189 acc = min(acc, counters["@event keypressed"])
1190 acc = min(acc, counters["handling input"])
1191 counters["handling input"] = max(counters["handling input"] - acc, 0)
1192 counters["@event keypressed"] = max(counters["@event keypressed"] - acc, 0)
1193 counters["@save key pressed"] = counters["@save key pressed"] + acc * 1
1194 counters["handling input"] = counters["handling input"] + acc * 1
1195 counters["spawn 100 circles"] = counters["spawn 100 circles"] + acc * 1
1196 return true
1197 end
1198 if counters["handling input"] > 0 and counters["@event mousepressed"] > 0 then
1199 local acc = huge
1200 acc = min(acc, counters["@event mousepressed"])
1201 acc = min(acc, counters["handling input"])
1202 counters["handling input"] = max(counters["handling input"] - acc, 0)
1203 counters["@event mousepressed"] = max(counters["@event mousepressed"] - acc, 0)
1204 counters["shoot bullet"] = counters["shoot bullet"] + acc * 1
1205 counters["handling inputs"] = counters["handling inputs"] + acc * 1
1206 return true
1207 end
1208 if counters["clear @circle index"] > 0 and counters["@circle index"] > 0 then
1209 local acc = huge
1210 acc = min(acc, counters["@circle index"])
1211 acc = min(acc, counters["clear @circle index"])
1212 counters["clear @circle index"] = max(counters["clear @circle index"] - acc, 0)
1213 counters["@circle index"] = max(counters["@circle index"] - acc, 0)
1214 counters["clear @circle index"] = counters["clear @circle index"] + acc * 1
1215 return true
1216 end
1217 if counters["clear @circle index"] > 0 then
1218 local acc = counters["clear @circle index"]
1219 counters["clear @circle index"] = max(counters["clear @circle index"] - acc, 0)
1220 return true
1221 end
1222 if counters["reset @circle index"] > 0 then
1223 local acc = counters["reset @circle index"]
1224 counters["reset @circle index"] = max(counters["reset @circle index"] - acc, 0)
1225 counters["clear @circle index:9007199254740991"] = counters["clear @circle index:9007199254740991"] + acc * 1
1226 return true
1227 end
1228 if counters["get random number"] > 0 then
1229 local acc = counters["get random number"]
1230 counters["get random number"] = max(counters["get random number"] - acc, 0)
1231 counters["@get random number"] = counters["@get random number"] + acc * 1
1232 return true
1233 end
1234 if counters["@number -> @new circle x"] > 0 and counters["@number"] > 0 then
1235 local acc = huge
1236 acc = min(acc, counters["@number"])
1237 acc = min(acc, counters["@number -> @new circle x"])
1238 counters["@number -> @new circle x"] = max(counters["@number -> @new circle x"] - acc, 0)
1239 counters["@number"] = max(counters["@number"] - acc, 0)
1240 counters["@new circle x"] = counters["@new circle x"] + acc * 1
1241 counters["@number -> @new circle x"] = counters["@number -> @new circle x"] + acc * 1
1242 return true
1243 end
1244 if counters["@number -> @new circle x"] > 0 then
1245 local acc = counters["@number -> @new circle x"]
1246 counters["@number -> @new circle x"] = max(counters["@number -> @new circle x"] - acc, 0)
1247 return true
1248 end
1249 if counters["@number -> @new circle y"] > 0 and counters["@number"] > 0 then
1250 local acc = huge
1251 acc = min(acc, counters["@number -> @new circle y"])
1252 acc = min(acc, counters["@number"])
1253 counters["@number -> @new circle y"] = max(counters["@number -> @new circle y"] - acc, 0)
1254 counters["@number"] = max(counters["@number"] - acc, 0)
1255 counters["@number -> @new circle y"] = counters["@number -> @new circle y"] + acc * 1
1256 counters["@new circle y"] = counters["@new circle y"] + acc * 1
1257 return true
1258 end
1259 if counters["@number -> @new circle y"] > 0 then
1260 local acc = counters["@number -> @new circle y"]
1261 counters["@number -> @new circle y"] = max(counters["@number -> @new circle y"] - acc, 0)
1262 return true
1263 end
1264 if counters["@number -> @new circle r"] > 0 and counters["@number"] > 0 then
1265 local acc = huge
1266 acc = min(acc, counters["@number"])
1267 acc = min(acc, counters["@number -> @new circle r"])
1268 counters["@number -> @new circle r"] = max(counters["@number -> @new circle r"] - acc, 0)
1269 counters["@number"] = max(counters["@number"] - acc, 0)
1270 counters["@new circle r"] = counters["@new circle r"] + acc * 1
1271 counters["@number -> @new circle r"] = counters["@number -> @new circle r"] + acc * 1
1272 return true
1273 end
1274 if counters["@number -> @new circle r"] > 0 then
1275 local acc = counters["@number -> @new circle r"]
1276 counters["@number -> @new circle r"] = max(counters["@number -> @new circle r"] - acc, 0)
1277 return true
1278 end
1279 if counters["@number -> @new circle speed"] > 0 and counters["@number"] > 0 then
1280 local acc = huge
1281 acc = min(acc, counters["@number -> @new circle speed"])
1282 acc = min(acc, counters["@number"])
1283 counters["@number -> @new circle speed"] = max(counters["@number -> @new circle speed"] - acc, 0)
1284 counters["@number"] = max(counters["@number"] - acc, 0)
1285 counters["@number -> @new circle speed"] = counters["@number -> @new circle speed"] + acc * 1
1286 counters["@new circle speed"] = counters["@new circle speed"] + acc * 1
1287 return true
1288 end
1289 if counters["@number -> @new circle speed"] > 0 then
1290 local acc = counters["@number -> @new circle speed"]
1291 counters["@number -> @new circle speed"] = max(counters["@number -> @new circle speed"] - acc, 0)
1292 return true
1293 end
1294 if counters["move @number to @new circle x"] > 0 then
1295 local acc = counters["move @number to @new circle x"]
1296 counters["move @number to @new circle x"] = max(counters["move @number to @new circle x"] - acc, 0)
1297 counters["@number -> @new circle x:9007199254740991"] = counters["@number -> @new circle x:9007199254740991"] + acc * 1
1298 return true
1299 end
1300 if counters["move @number to @new circle y"] > 0 then
1301 local acc = counters["move @number to @new circle y"]
1302 counters["move @number to @new circle y"] = max(counters["move @number to @new circle y"] - acc, 0)
1303 counters["@number -> @new circle y:9007199254740991"] = counters["@number -> @new circle y:9007199254740991"] + acc * 1
1304 return true
1305 end
1306 if counters["move @number to @new circle r"] > 0 then
1307 local acc = counters["move @number to @new circle r"]
1308 counters["move @number to @new circle r"] = max(counters["move @number to @new circle r"] - acc, 0)
1309 counters["@number -> @new circle r:9007199254740991"] = counters["@number -> @new circle r:9007199254740991"] + acc * 1
1310 return true
1311 end
1312 if counters["move @number to @new circle speed"] > 0 then
1313 local acc = counters["move @number to @new circle speed"]
1314 counters["move @number to @new circle speed"] = max(counters["move @number to @new circle speed"] - acc, 0)
1315 counters["@number -> @new circle speed:9007199254740991"] = counters["@number -> @new circle speed:9007199254740991"] + acc * 1
1316 return true
1317 end
1318 if counters["generate x position"] > 0 then
1319 local acc = counters["generate x position"]
1320 counters["generate x position"] = max(counters["generate x position"] - acc, 0)
1321 counters["@random max:775"] = counters["@random max:775"] + acc * 1
1322 counters["move @number to @new circle x"] = counters["move @number to @new circle x"] + acc * 1
1323 counters["@random min:25"] = counters["@random min:25"] + acc * 1
1324 counters["get random number"] = counters["get random number"] + acc * 1
1325 return true
1326 end
1327 if counters["generate y position"] > 0 then
1328 local acc = counters["generate y position"]
1329 counters["generate y position"] = max(counters["generate y position"] - acc, 0)
1330 counters["move @number to @new circle y"] = counters["move @number to @new circle y"] + acc * 1
1331 counters["@random max:575"] = counters["@random max:575"] + acc * 1
1332 counters["@random min:25"] = counters["@random min:25"] + acc * 1
1333 counters["get random number"] = counters["get random number"] + acc * 1
1334 return true
1335 end
1336 if counters["generate radius"] > 0 then
1337 local acc = counters["generate radius"]
1338 counters["generate radius"] = max(counters["generate radius"] - acc, 0)
1339 counters["@random max:3"] = counters["@random max:3"] + acc * 1
1340 counters["move @number to @new circle r"] = counters["move @number to @new circle r"] + acc * 1
1341 counters["@random min:1"] = counters["@random min:1"] + acc * 1
1342 counters["get random number"] = counters["get random number"] + acc * 1
1343 return true
1344 end
1345 if counters["generate speed"] > 0 then
1346 local acc = counters["generate speed"]
1347 counters["generate speed"] = max(counters["generate speed"] - acc, 0)
1348 counters["move @number to @new circle speed"] = counters["move @number to @new circle speed"] + acc * 1
1349 counters["@random max:5"] = counters["@random max:5"] + acc * 1
1350 counters["get random number"] = counters["get random number"] + acc * 1
1351 counters["@random min:2"] = counters["@random min:2"] + acc * 1
1352 return true
1353 end
1354 if counters["make new circle"] > 0 then
1355 local acc = counters["make new circle"]
1356 counters["make new circle"] = max(counters["make new circle"] - acc, 0)
1357 counters["@new circle"] = counters["@new circle"] + acc * 1
1358 return true
1359 end
1360 if counters["make circle"] > 0 then
1361 local acc = counters["make circle"]
1362 counters["make circle"] = max(counters["make circle"] - acc, 0)
1363 counters["generate x position"] = counters["generate x position"] + acc * 1
1364 counters["generate y position"] = counters["generate y position"] + acc * 1
1365 counters["generate radius"] = counters["generate radius"] + acc * 1
1366 counters["make new circle"] = counters["make new circle"] + acc * 1
1367 counters["generate speed"] = counters["generate speed"] + acc * 1
1368 return true
1369 end
1370 if counters["circle count => iteration"] > 0 and counters["circle count"] > 0 then
1371 local acc = huge
1372 acc = min(acc, counters["circle count"])
1373 acc = min(acc, counters["circle count => iteration"])
1374 counters["circle count => iteration"] = max(counters["circle count => iteration"] - acc, 0)
1375 counters["circle count"] = max(counters["circle count"] - acc, 0)
1376 counters["iteration"] = counters["iteration"] + acc * 1
1377 counters["copied circle count"] = counters["copied circle count"] + acc * 1
1378 return true
1379 end
1380 if counters["circle count => iteration"] > 0 then
1381 local acc = counters["circle count => iteration"]
1382 counters["circle count => iteration"] = max(counters["circle count => iteration"] - acc, 0)
1383 return true
1384 end
1385 if counters["copied circle count"] > 0 then
1386 local acc = counters["copied circle count"]
1387 counters["copied circle count"] = max(counters["copied circle count"] - acc, 0)
1388 counters["circle count"] = counters["circle count"] + acc * 1
1389 return true
1390 end
1391 if counters["copy circle count to iteration"] > 0 then
1392 local acc = counters["copy circle count to iteration"]
1393 counters["copy circle count to iteration"] = max(counters["copy circle count to iteration"] - acc, 0)
1394 counters["circle count => iteration:9007199254740991"] = counters["circle count => iteration:9007199254740991"] + acc * 1
1395 return true
1396 end
1397 if counters["draw each circle"] > 0 and counters["iteration"] > 0 then
1398 local acc = huge
1399 acc = min(acc, counters["draw each circle"])
1400 acc = min(acc, counters["iteration"])
1401 counters["draw each circle"] = max(counters["draw each circle"] - acc, 0)
1402 counters["iteration"] = max(counters["iteration"] - acc, 0)
1403 counters["draw each circle"] = counters["draw each circle"] + acc * 1
1404 counters["@draw circle"] = counters["@draw circle"] + acc * 1
1405 counters["@circle index"] = counters["@circle index"] + acc * 1
1406 return true
1407 end
1408 if counters["draw each circle"] > 0 then
1409 local acc = counters["draw each circle"]
1410 counters["draw each circle"] = max(counters["draw each circle"] - acc, 0)
1411 return true
1412 end
1413 if counters["draw circles"] > 0 then
1414 local acc = counters["draw circles"]
1415 counters["draw circles"] = max(counters["draw circles"] - acc, 0)
1416 counters["copy circle count to iteration"] = counters["copy circle count to iteration"] + acc * 1
1417 counters["reset @circle index"] = counters["reset @circle index"] + acc * 1
1418 counters["draw each circle"] = counters["draw each circle"] + acc * 1
1419 return true
1420 end
1421 if counters["print fps"] > 0 then
1422 local acc = counters["print fps"]
1423 counters["print fps"] = max(counters["print fps"] - acc, 0)
1424 counters["@print fps"] = counters["@print fps"] + acc * 1
1425 return true
1426 end
1427 if counters["print key pressed"] > 0 then
1428 local acc = counters["print key pressed"]
1429 counters["print key pressed"] = max(counters["print key pressed"] - acc, 0)
1430 counters["@print key pressed"] = counters["@print key pressed"] + acc * 1
1431 return true
1432 end
1433 if counters["drawing scene"] > 0 then
1434 local acc = counters["drawing scene"]
1435 counters["drawing scene"] = max(counters["drawing scene"] - acc, 0)
1436 counters["draw circles"] = counters["draw circles"] + acc * 1
1437 counters["print key pressed"] = counters["print key pressed"] + acc * 1
1438 counters["print fps"] = counters["print fps"] + acc * 1
1439 return true
1440 end
1441 if counters["move each circle"] > 0 and counters["iteration"] > 0 then
1442 local acc = huge
1443 acc = min(acc, counters["move each circle"])
1444 acc = min(acc, counters["iteration"])
1445 counters["move each circle"] = max(counters["move each circle"] - acc, 0)
1446 counters["iteration"] = max(counters["iteration"] - acc, 0)
1447 counters["@move circle"] = counters["@move circle"] + acc * 1
1448 counters["move each circle"] = counters["move each circle"] + acc * 1
1449 counters["@circle index"] = counters["@circle index"] + acc * 1
1450 return true
1451 end
1452 if counters["move each circle"] > 0 then
1453 local acc = counters["move each circle"]
1454 counters["move each circle"] = max(counters["move each circle"] - acc, 0)
1455 return true
1456 end
1457 if counters["update circles"] > 0 then
1458 local acc = counters["update circles"]
1459 counters["update circles"] = max(counters["update circles"] - acc, 0)
1460 counters["copy circle count to iteration"] = counters["copy circle count to iteration"] + acc * 1
1461 counters["reset @circle index"] = counters["reset @circle index"] + acc * 1
1462 counters["move each circle"] = counters["move each circle"] + acc * 1
1463 return true
1464 end
1465 if counters["updating scene"] > 0 then
1466 local acc = counters["updating scene"]
1467 counters["updating scene"] = max(counters["updating scene"] - acc, 0)
1468 counters["update circles"] = counters["update circles"] + acc * 1
1469 return true
1470 end
1471 if counters["handling input"] > 0 and counters["@event keypressed"] > 0 then
1472 local acc = huge
1473 acc = min(acc, counters["@event keypressed"])
1474 acc = min(acc, counters["handling input"])
1475 counters["handling input"] = max(counters["handling input"] - acc, 0)
1476 counters["@event keypressed"] = max(counters["@event keypressed"] - acc, 0)
1477 counters["@save key pressed"] = counters["@save key pressed"] + acc * 1
1478 counters["spawn 100 circles"] = counters["spawn 100 circles"] + acc * 1
1479 return true
1480 end
1481 if counters["spawn 100 circles"] > 0 then
1482 local acc = counters["spawn 100 circles"]
1483 counters["spawn 100 circles"] = max(counters["spawn 100 circles"] - acc, 0)
1484 counters["make circles:100"] = counters["make circles:100"] + acc * 1
1485 return true
1486 end
1487 if counters["make circles"] > 0 and counters["@once"] > 0 then
1488 local acc = huge
1489 acc = min(acc, counters["make circles"])
1490 acc = min(acc, counters["@once"])
1491 counters["make circles"] = max(counters["make circles"] - acc, 0)
1492 counters["@once"] = max(counters["@once"] - acc, 0)
1493 counters["circle count"] = counters["circle count"] + acc * 1
1494 counters["@once"] = counters["@once"] + acc * 1
1495 counters["make circle"] = counters["make circle"] + acc * 1
1496 return true
1497 end
1498 if counters["make circles"] > 0 and counters["@once"] > 0 then
1499 local acc = huge
1500 acc = min(acc, counters["make circles"])
1501 acc = min(acc, counters["@once"])
1502 counters["make circles"] = max(counters["make circles"] - acc, 0)
1503 counters["@once"] = max(counters["@once"] - acc, 0)
1504 return true
1505 end
1506 if counters["handling input"] > 0 and counters["@event mousepressed"] > 0 then
1507 local acc = huge
1508 acc = min(acc, counters["@event mousepressed"])
1509 acc = min(acc, counters["handling input"])
1510 counters["handling input"] = max(counters["handling input"] - acc, 0)
1511 counters["@event mousepressed"] = max(counters["@event mousepressed"] - acc, 0)
1512 counters["shoot bullet"] = counters["shoot bullet"] + acc * 1
1513 return true
1514 end
1515 if counters["shoot bullet"] > 0 then
1516 local acc = counters["shoot bullet"]
1517 counters["shoot bullet"] = max(counters["shoot bullet"] - acc, 0)
1518 counters["@shoot bullet"] = counters["@shoot bullet"] + acc * 1
1519 return true
1520 end
1521 if counters["drawing scene"] > 0 then
1522 local acc = counters["drawing scene"]
1523 counters["drawing scene"] = max(counters["drawing scene"] - acc, 0)
1524 counters["draw zombies"] = counters["draw zombies"] + acc * 1
1525 counters["draw player"] = counters["draw player"] + acc * 1
1526 counters["@print fps"] = counters["@print fps"] + acc * 1
1527 counters["draw bullets"] = counters["draw bullets"] + acc * 1
1528 return true
1529 end
1530 if counters["draw player"] > 0 then
1531 local acc = counters["draw player"]
1532 counters["draw player"] = max(counters["draw player"] - acc, 0)
1533 counters["@draw player"] = counters["@draw player"] + acc * 1
1534 return true
1535 end
1536 if counters["draw bullets"] > 0 then
1537 local acc = counters["draw bullets"]
1538 counters["draw bullets"] = max(counters["draw bullets"] - acc, 0)
1539 counters["@draw bullets"] = counters["@draw bullets"] + acc * 1
1540 return true
1541 end
1542 if counters["draw zombies"] > 0 then
1543 local acc = counters["draw zombies"]
1544 counters["draw zombies"] = max(counters["draw zombies"] - acc, 0)
1545 counters["@draw zombies"] = counters["@draw zombies"] + acc * 1
1546 return true
1547 end
1548 if counters["updating scene"] > 0 then
1549 local acc = counters["updating scene"]
1550 counters["updating scene"] = max(counters["updating scene"] - acc, 0)
1551 counters["move player"] = counters["move player"] + acc * 1
1552 counters["check for collisions"] = counters["check for collisions"] + acc * 1
1553 counters["sweep deleted entities"] = counters["sweep deleted entities"] + acc * 1
1554 counters["update spawn timer"] = counters["update spawn timer"] + acc * 1
1555 counters["move bullets"] = counters["move bullets"] + acc * 1
1556 counters["move zombies"] = counters["move zombies"] + acc * 1
1557 return true
1558 end
1559 if counters["move player"] > 0 then
1560 local acc = counters["move player"]
1561 counters["move player"] = max(counters["move player"] - acc, 0)
1562 counters["@is [move right] down?"] = counters["@is [move right] down?"] + acc * 1
1563 counters["@is [move down] down?"] = counters["@is [move down] down?"] + acc * 1
1564 counters["moving player"] = counters["moving player"] + acc * 1
1565 counters["@is [move left] down?"] = counters["@is [move left] down?"] + acc * 1
1566 counters["@is [move up] down?"] = counters["@is [move up] down?"] + acc * 1
1567 return true
1568 end
1569 if counters["moving player"] > 0 and counters["@[move up] is down"] > 0 then
1570 local acc = huge
1571 acc = min(acc, counters["moving player"])
1572 acc = min(acc, counters["@[move up] is down"])
1573 counters["moving player"] = max(counters["moving player"] - acc, 0)
1574 counters["@[move up] is down"] = max(counters["@[move up] is down"] - acc, 0)
1575 counters["moving player"] = counters["moving player"] + acc * 1
1576 counters["@dir up"] = counters["@dir up"] + acc * 1
1577 return true
1578 end
1579 if counters["moving player"] > 0 and counters["@[move left] is down"] > 0 then
1580 local acc = huge
1581 acc = min(acc, counters["moving player"])
1582 acc = min(acc, counters["@[move left] is down"])
1583 counters["moving player"] = max(counters["moving player"] - acc, 0)
1584 counters["@[move left] is down"] = max(counters["@[move left] is down"] - acc, 0)
1585 counters["moving player"] = counters["moving player"] + acc * 1
1586 counters["@dir left"] = counters["@dir left"] + acc * 1
1587 return true
1588 end
1589 if counters["moving player"] > 0 and counters["@[move down] is down"] > 0 then
1590 local acc = huge
1591 acc = min(acc, counters["moving player"])
1592 acc = min(acc, counters["@[move down] is down"])
1593 counters["moving player"] = max(counters["moving player"] - acc, 0)
1594 counters["@[move down] is down"] = max(counters["@[move down] is down"] - acc, 0)
1595 counters["moving player"] = counters["moving player"] + acc * 1
1596 counters["@dir down"] = counters["@dir down"] + acc * 1
1597 return true
1598 end
1599 if counters["moving player"] > 0 and counters["@[move right] is down"] > 0 then
1600 local acc = huge
1601 acc = min(acc, counters["moving player"])
1602 acc = min(acc, counters["@[move right] is down"])
1603 counters["moving player"] = max(counters["moving player"] - acc, 0)
1604 counters["@[move right] is down"] = max(counters["@[move right] is down"] - acc, 0)
1605 counters["moving player"] = counters["moving player"] + acc * 1
1606 counters["@dir right"] = counters["@dir right"] + acc * 1
1607 return true
1608 end
1609 if counters["@dir left"] > 0 and counters["@dir right"] > 0 then
1610 local acc = huge
1611 acc = min(acc, counters["@dir right"])
1612 acc = min(acc, counters["@dir left"])
1613 counters["@dir left"] = max(counters["@dir left"] - acc, 0)
1614 counters["@dir right"] = max(counters["@dir right"] - acc, 0)
1615 return true
1616 end
1617 if counters["@dir down"] > 0 and counters["@dir up"] > 0 then
1618 local acc = huge
1619 acc = min(acc, counters["@dir up"])
1620 acc = min(acc, counters["@dir down"])
1621 counters["@dir down"] = max(counters["@dir down"] - acc, 0)
1622 counters["@dir up"] = max(counters["@dir up"] - acc, 0)
1623 return true
1624 end
1625 if counters["moving player"] > 0 then
1626 local acc = counters["moving player"]
1627 counters["moving player"] = max(counters["moving player"] - acc, 0)
1628 counters["@move player"] = counters["@move player"] + acc * 1
1629 return true
1630 end
1631 if counters["move bullets"] > 0 then
1632 local acc = counters["move bullets"]
1633 counters["move bullets"] = max(counters["move bullets"] - acc, 0)
1634 counters["@move bullets"] = counters["@move bullets"] + acc * 1
1635 return true
1636 end
1637 if counters["move zombies"] > 0 then
1638 local acc = counters["move zombies"]
1639 counters["move zombies"] = max(counters["move zombies"] - acc, 0)
1640 counters["@move zombies"] = counters["@move zombies"] + acc * 1
1641 return true
1642 end
1643 if counters["check for collisions"] > 0 then
1644 local acc = counters["check for collisions"]
1645 counters["check for collisions"] = max(counters["check for collisions"] - acc, 0)
1646 counters["check for player hit by zombie"] = counters["check for player hit by zombie"] + acc * 1
1647 counters["check for bullet hitting zombie"] = counters["check for bullet hitting zombie"] + acc * 1
1648 return true
1649 end
1650 if counters["check for player hit by zombie"] > 0 then
1651 local acc = counters["check for player hit by zombie"]
1652 counters["check for player hit by zombie"] = max(counters["check for player hit by zombie"] - acc, 0)
1653 counters["@do player collisions"] = counters["@do player collisions"] + acc * 1
1654 return true
1655 end
1656 if counters["check for bullet hitting zombie"] > 0 then
1657 local acc = counters["check for bullet hitting zombie"]
1658 counters["check for bullet hitting zombie"] = max(counters["check for bullet hitting zombie"] - acc, 0)
1659 counters["@do bullet collisions"] = counters["@do bullet collisions"] + acc * 1
1660 return true
1661 end
1662 if counters["update spawn timer"] > 0 then
1663 local acc = counters["update spawn timer"]
1664 counters["update spawn timer"] = max(counters["update spawn timer"] - acc, 0)
1665 counters["@update spawn timer"] = counters["@update spawn timer"] + acc * 1
1666 return true
1667 end
1668 if counters["@spawn timer expired"] > 0 then
1669 local acc = counters["@spawn timer expired"]
1670 counters["@spawn timer expired"] = max(counters["@spawn timer expired"] - acc, 0)
1671 counters["spawn a zombie"] = counters["spawn a zombie"] + acc * 1
1672 counters["make the timer faster"] = counters["make the timer faster"] + acc * 1
1673 counters["reset timer"] = counters["reset timer"] + acc * 1
1674 return true
1675 end
1676 if counters["spawn a zombie"] > 0 then
1677 local acc = counters["spawn a zombie"]
1678 counters["spawn a zombie"] = max(counters["spawn a zombie"] - acc, 0)
1679 counters["@spawn a zombie"] = counters["@spawn a zombie"] + acc * 1
1680 return true
1681 end
1682 if counters["make the timer faster"] > 0 then
1683 local acc = counters["make the timer faster"]
1684 counters["make the timer faster"] = max(counters["make the timer faster"] - acc, 0)
1685 counters["@make the timer faster"] = counters["@make the timer faster"] + acc * 1
1686 return true
1687 end
1688 if counters["reset timer"] > 0 then
1689 local acc = counters["reset timer"]
1690 counters["reset timer"] = max(counters["reset timer"] - acc, 0)
1691 counters["@reset timer"] = counters["@reset timer"] + acc * 1
1692 return true
1693 end
1694 if counters["sweep deleted entities"] > 0 then
1695 local acc = counters["sweep deleted entities"]
1696 counters["sweep deleted entities"] = max(counters["sweep deleted entities"] - acc, 0)
1697 counters["@delete out of bounds bullets"] = counters["@delete out of bounds bullets"] + acc * 1
1698 counters["@delete killed zombies"] = counters["@delete killed zombies"] + acc * 1
1699 return true
1700 end
1701 if counters["handling input"] > 0 then
1702 local acc = counters["handling input"]
1703 counters["handling input"] = max(counters["handling input"] - acc, 0)
1704 return true
1705 end
1706 if counters["updating scene"] > 0 then
1707 local acc = counters["updating scene"]
1708 counters["updating scene"] = max(counters["updating scene"] - acc, 0)
1709 return true
1710 end
1711 if counters["drawing scene"] > 0 then
1712 local acc = counters["drawing scene"]
1713 counters["drawing scene"] = max(counters["drawing scene"] - acc, 0)
1714 return true
1715 end
1716 if counters["run main loop"] > 0 then
1717 local acc = counters["run main loop"]
1718 counters["run main loop"] = max(counters["run main loop"] - acc, 0)
1719 counters["run current frame"] = counters["run current frame"] + acc * 1
1720 counters["start polling inputs"] = counters["start polling inputs"] + acc * 1
1721 counters["handle input"] = counters["handle input"] + acc * 1
1722 counters["poll input"] = counters["poll input"] + acc * 1
1723 return true
1724 end
1725 if counters["start polling inputs"] > 0 then
1726 local acc = counters["start polling inputs"]
1727 counters["start polling inputs"] = max(counters["start polling inputs"] - acc, 0)
1728 counters["@start polling"] = counters["@start polling"] + acc * 1
1729 return true
1730 end
1731 if counters["poll input"] > 0 then
1732 local acc = counters["poll input"]
1733 counters["poll input"] = max(counters["poll input"] - acc, 0)
1734 counters["@poll input"] = counters["@poll input"] + acc * 1
1735 return true
1736 end
1737 if counters["handle input"] > 0 and counters["@no events left"] > 0 then
1738 local acc = huge
1739 acc = min(acc, counters["handle input"])
1740 acc = min(acc, counters["@no events left"])
1741 counters["handle input"] = max(counters["handle input"] - acc, 0)
1742 counters["@no events left"] = max(counters["@no events left"] - acc, 0)
1743 return true
1744 end
1745 if counters["handle input"] > 0 then
1746 local acc = counters["handle input"]
1747 counters["handle input"] = max(counters["handle input"] - acc, 0)
1748 counters["handling input"] = counters["handling input"] + acc * 1
1749 counters["handle input"] = counters["handle input"] + acc * 1
1750 counters["poll input"] = counters["poll input"] + acc * 1
1751 return true
1752 end
1753 if counters["run current frame"] > 0 and counters["@event quit"] > 0 then
1754 local acc = huge
1755 acc = min(acc, counters["run current frame"])
1756 acc = min(acc, counters["@event quit"])
1757 counters["run current frame"] = max(counters["run current frame"] - acc, 0)
1758 counters["@event quit"] = max(counters["@event quit"] - acc, 0)
1759 counters["@quit love"] = counters["@quit love"] + acc * 1
1760 return true
1761 end
1762 if counters["run current frame"] > 0 then
1763 local acc = counters["run current frame"]
1764 counters["run current frame"] = max(counters["run current frame"] - acc, 0)
1765 counters["clear the screen"] = counters["clear the screen"] + acc * 1
1766 counters["update scene state"] = counters["update scene state"] + acc * 1
1767 counters["draw scene"] = counters["draw scene"] + acc * 1
1768 counters["present current frame"] = counters["present current frame"] + acc * 1
1769 counters["sleep for 1ms"] = counters["sleep for 1ms"] + acc * 1
1770 counters["next cycle"] = counters["next cycle"] + acc * 1
1771 counters["step timer"] = counters["step timer"] + acc * 1
1772 return true
1773 end
1774 if counters["step timer"] > 0 then
1775 local acc = counters["step timer"]
1776 counters["step timer"] = max(counters["step timer"] - acc, 0)
1777 counters["@step timer"] = counters["@step timer"] + acc * 1
1778 return true
1779 end
1780 if counters["clear the screen"] > 0 then
1781 local acc = counters["clear the screen"]
1782 counters["clear the screen"] = max(counters["clear the screen"] - acc, 0)
1783 counters["@clear screen"] = counters["@clear screen"] + acc * 1
1784 return true
1785 end
1786 if counters["update scene state"] > 0 then
1787 local acc = counters["update scene state"]
1788 counters["update scene state"] = max(counters["update scene state"] - acc, 0)
1789 counters["updating scene"] = counters["updating scene"] + acc * 1
1790 return true
1791 end
1792 if counters["draw scene"] > 0 then
1793 local acc = counters["draw scene"]
1794 counters["draw scene"] = max(counters["draw scene"] - acc, 0)
1795 counters["drawing scene"] = counters["drawing scene"] + acc * 1
1796 return true
1797 end
1798 if counters["present current frame"] > 0 then
1799 local acc = counters["present current frame"]
1800 counters["present current frame"] = max(counters["present current frame"] - acc, 0)
1801 counters["@present"] = counters["@present"] + acc * 1
1802 return true
1803 end
1804 if counters["sleep for 1ms"] > 0 then
1805 local acc = counters["sleep for 1ms"]
1806 counters["sleep for 1ms"] = max(counters["sleep for 1ms"] - acc, 0)
1807 counters["@ms"] = counters["@ms"] + acc * 1
1808 return true
1809 end
1810 if counters["next cycle"] > 0 then
1811 local acc = counters["next cycle"]
1812 counters["next cycle"] = max(counters["next cycle"] - acc, 0)
1813 counters["run main loop"] = counters["run main loop"] + acc * 1
1814 return true
1815 end
1816 return false
1817end
1818
1819function machine:run()
1820 local counters = self.counters
1821 while match(self, counters) do end
1822end
1823
1824return machine
zz-zombies.lua Orginalformat Playground
1local min, max, huge = math.min, math.max, math.huge
2local machine = {state = {}}
3
4machine.counters = {
5 ["@move player"] = 0,
6 ["@[move up] is down"] = 0,
7 ["@is [move up] down?"] = 0,
8 ["@exit code"] = 0,
9 ["@is [move left] down?"] = 0,
10 ["@is [move down] down?"] = 0,
11 ["handling input"] = 0,
12 ["@is [move right] down?"] = 0,
13 ["run main loop"] = 1,
14 ["start polling inputs"] = 0,
15 ["@shoot bullet"] = 0,
16 ["poll input"] = 0,
17 ["@move bullets"] = 0,
18 ["@delete out of bounds bullets"] = 0,
19 ["@draw bullets"] = 0,
20 ["@update spawn timer"] = 0,
21 ["@make the timer faster"] = 0,
22 ["@reset timer"] = 0,
23 ["@do player collisions"] = 0,
24 ["@spawn a zombie"] = 0,
25 ["@[move left] is down"] = 0,
26 ["@[move down] is down"] = 0,
27 ["@delete killed zombies"] = 0,
28 ["@[move right] is down"] = 0,
29 ["@event keyreleased"] = 0,
30 ["@event mousemoved"] = 0,
31 ["shoot bullet"] = 0,
32 ["drawing scene"] = 0,
33 ["@do bullet collisions"] = 0,
34 ["draw player"] = 0,
35 ["draw bullets"] = 0,
36 ["@start polling"] = 0,
37 ["draw zombies"] = 0,
38 ["updating scene"] = 0,
39 ["@quit love"] = 0,
40 ["@dir up"] = 0,
41 ["@dir down"] = 0,
42 ["@poll input"] = 0,
43 ["@clear screen"] = 0,
44 ["@dir right"] = 0,
45 ["moving player"] = 0,
46 ["move bullets"] = 0,
47 ["@sleep"] = 0,
48 ["move zombies"] = 0,
49 ["@ms"] = 0,
50 ["check for player hit by zombie"] = 0,
51 ["check for bullet hitting zombie"] = 0,
52 ["update spawn timer"] = 0,
53 ["@no events left"] = 0,
54 ["@spawn timer expired"] = 0,
55 ["spawn a zombie"] = 0,
56 ["make the timer faster"] = 0,
57 ["run current frame"] = 0,
58 ["reset timer"] = 0,
59 ["step timer"] = 0,
60 ["sweep deleted entities"] = 0,
61 ["clear the screen"] = 0,
62 ["update scene state"] = 0,
63 ["draw scene"] = 0,
64 ["present current frame"] = 0,
65 ["sleep for 1ms"] = 0,
66 ["@event quit"] = 0,
67 ["next cycle"] = 0,
68 ["handle input"] = 0,
69 ["@draw zombies"] = 0,
70 ["@dir left"] = 0,
71 ["@move zombies"] = 0,
72 ["@print fps"] = 0,
73 ["@present"] = 0,
74 ["@event keypressed"] = 0,
75 ["@event mousepressed"] = 0,
76 ["@draw player"] = 0,
77 ["move player"] = 0,
78 ["check for collisions"] = 0,
79 ["@step timer"] = 0,
80}
81
82machine.state = {
83 ["player"] = {x = 400, y = 300, r = 10, health = 5},
84 ["bullets"] = {},
85 ["event_args"] = {},
86 ["spawn_timer"] = { time_left = 1, duration = 1 },
87 ["dt"] = 0,
88 ["zombies"] = {},
89}
90
91function machine:on_print_fps(counters)
92 love.graphics.setColor(1, 0, 0)
93 love.graphics.print(
94 tostring(love.timer.getFPS())
95 .. " bullets: " .. tostring(#self.state.bullets)
96 .. " zombies: " .. tostring(#self.state.zombies)
97 , 10, 10)
98 love.graphics.setColor(1, 1, 1)
99
100
101end
102
103function machine:on_draw_player(counters)
104 local player = self.state.player
105 love.graphics.setColor(0, 1, 0)
106 love.graphics.circle("fill", player.x, player.y, player.r)
107 love.graphics.setColor(1, 1, 1)
108
109
110end
111
112function machine:on_move_player(counters, dir_up, dir_down, dir_left, dir_right)
113 local player = self.state.player
114 local dir_y = (dir_down - dir_up)
115 local dir_x = (dir_right - dir_left)
116 player.x = player.x + dir_x * self.state.dt * 300
117 player.y = player.y + dir_y * self.state.dt * 300
118
119
120end
121
122function machine:on_is_move_up_down(counters)
123 if love.keyboard.isDown("w") then
124 counters["@[move up] is down"] = 1
125 end
126
127
128end
129
130function machine:on_is_move_left_down(counters)
131 if love.keyboard.isDown("a") then
132 counters["@[move left] is down"] = 1
133 end
134
135
136end
137
138function machine:on_is_move_down_down(counters)
139 if love.keyboard.isDown("s") then
140 counters["@[move down] is down"] = 1
141 end
142
143
144end
145
146function machine:on_is_move_right_down(counters)
147 if love.keyboard.isDown("d") then
148 counters["@[move right] is down"] = 1
149 end
150
151
152end
153
154function machine:on_shoot_bullet(counters)
155 local bullets = self.state.bullets
156 local px, py = self.state.player.x, self.state.player.y
157 local mx, my = love.mouse.getPosition()
158 local angle = math.atan2(my - py, mx - px)
159 table.insert(bullets, {x = px, y = py, angle = angle, r = 5})
160
161
162end
163
164function machine:on_move_bullets(counters)
165 local dt = self.state.dt
166 local bullets = self.state.bullets
167 for _, bullet in ipairs(bullets) do
168 bullet.x = bullet.x + math.cos(bullet.angle) * 350 * dt
169 bullet.y = bullet.y + math.sin(bullet.angle) * 350 * dt
170 local in_bounds
171 = -10 <= bullet.x and bullet.x <= 810
172 and -10 <= bullet.y and bullet.y <= 610
173 if not in_bounds then
174 bullet.deleted = true
175 end
176 end
177
178
179end
180
181function machine:on_delete_bullets(counters)
182 local bullets = self.state.bullets
183 local survivers = {}
184 for _, bullet in ipairs(bullets) do
185 if not bullet.deleted then
186 table.insert(survivers, bullet)
187 end
188 end
189 self.state.bullets = survivers
190
191
192end
193
194function machine:on_draw_bullets(counters)
195 local bullets = self.state.bullets
196 for _, bullet in ipairs(bullets) do
197 love.graphics.setColor(1, 1, 0)
198 love.graphics.circle("fill", bullet.x, bullet.y, bullet.r)
199 love.graphics.setColor(1, 1, 1)
200 end
201
202
203end
204
205function machine:on_update_spawn_timer(counters)
206 local spawn_timer = self.state.spawn_timer
207 spawn_timer.time_left = spawn_timer.time_left - self.state.dt
208 if 0 >= spawn_timer.time_left then
209 counters["@spawn timer expired"] = 1
210 end
211
212
213end
214
215function machine:on_make_the_timer_faster(counters)
216 local spawn_timer = self.state.spawn_timer
217 spawn_timer.duration = spawn_timer.duration - 0.0125
218
219
220end
221
222function machine:on_reset_timer(counters)
223 local spawn_timer = self.state.spawn_timer
224 spawn_timer.time_left = spawn_timer.duration
225
226
227end
228
229function machine:on_draw_zombies(counters)
230 local zombies = self.state.zombies
231 for _, zombie in ipairs(zombies) do
232 love.graphics.setColor(1, 0, 0)
233 love.graphics.circle("fill", zombie.x, zombie.y, zombie.r)
234 love.graphics.setColor(1, 0, 0)
235 end
236
237
238end
239
240function machine:on_spawn_a_zombie(counters)
241 local angle = math.random() * math.pi * 2
242 local x, y = math.cos(angle) * 450 + 400, math.sin(angle) * 350 + 300
243 table.insert(self.state.zombies, {x = x, y = y, health = 2, r = 10})
244
245
246end
247
248function machine:on_delete_killed_zombies(counters)
249 local zombies = self.state.zombies
250 local survivers = {}
251 for _, zombie in ipairs(zombies) do
252 if not zombie.dead then
253 table.insert(survivers, zombie)
254 end
255 end
256 self.state.zombies = survivers
257
258
259end
260
261function machine:on_move_zombies(counters)
262 local player = self.state.player
263 local zombies = self.state.zombies
264 for _, zombie in ipairs(zombies) do
265 local angle = math.atan2(player.y - zombie.y, player.x - zombie.x)
266 zombie.x = zombie.x + self.state.dt * math.cos(angle) * 310
267 zombie.y = zombie.y + self.state.dt * math.sin(angle) * 310
268 end
269
270
271end
272
273function machine:on_do_bullet_collisions(counters)
274 local bullets = self.state.bullets
275 local zombies = self.state.zombies
276
277 for _, bullet in ipairs(bullets) do
278 if bullet.deleted then goto next_bullet end
279 for _, zombie in ipairs(zombies) do
280 if zombie.dead then goto next_zombie end
281 local min_distance = bullet.r + zombie.r
282 local distance = math.sqrt((bullet.x - zombie.x) ^ 2 + (bullet.y - zombie.y) ^ 2)
283 if distance < min_distance then
284 zombie.health = zombie.health - 1
285 if zombie.health < 0 then
286 zombie.dead = true
287 end
288 bullet.deleted = true
289 end
290 ::next_zombie::
291 end
292 ::next_bullet::
293 end
294
295
296
297
298end
299
300function machine:on_start_polling(counters)
301 love.event.pump()
302 self.state.event_iter = love.event.poll()
303
304
305end
306
307function machine:on_poll_input(counters)
308 local name, a, b, c, d, e, f = self.state.event_iter()
309 if name then
310 local counter = "@event " .. name
311 if counters[counter] then
312 counters[counter] = 1
313 self.state.event_args[1] = a
314 self.state.event_args[2] = b
315 self.state.event_args[3] = c
316 self.state.event_args[4] = d
317 self.state.event_args[5] = e
318 self.state.event_args[6] = f
319 end
320 else
321 counters["@no events left"] = 1
322 end
323
324
325end
326
327function machine:on_quit_love(counters)
328 counters["@exit code"] = self.state.event_args[1] or 0
329
330
331end
332
333function machine:on_step_timer(counters)
334 self.state.dt = love.timer.step()
335
336
337end
338
339function machine:on_clear_screen(counters)
340 love.graphics.origin()
341 love.graphics.clear(love.graphics.getBackgroundColor())
342
343
344end
345
346function machine:on_present(counters)
347 love.graphics.present()
348
349
350end
351
352function machine:on_sleep(counters, ms)
353 love.timer.sleep(ms / 1000)
354
355
356end
357
358function match(self, counters)
359 if counters["@print fps"] > 0 then
360 self:on_print_fps(counters)
361 counters["@print fps"] = 0
362 return true
363 end
364 if counters["@draw player"] > 0 then
365 self:on_draw_player(counters)
366 counters["@draw player"] = 0
367 return true
368 end
369 if counters["@move player"] > 0 then
370 self:on_move_player(counters, counters["@dir up"], counters["@dir down"], counters["@dir left"], counters["@dir right"])
371 counters["@move player"] = 0
372 counters["@dir up"] = 0
373 counters["@dir down"] = 0
374 counters["@dir left"] = 0
375 counters["@dir right"] = 0
376 return true
377 end
378 if counters["@is [move up] down?"] > 0 then
379 counters["@[move up] is down"] = 0
380 self:on_is_move_up_down(counters)
381 counters["@is [move up] down?"] = 0
382 return true
383 end
384 if counters["@is [move left] down?"] > 0 then
385 counters["@[move left] is down"] = 0
386 self:on_is_move_left_down(counters)
387 counters["@is [move left] down?"] = 0
388 return true
389 end
390 if counters["@is [move down] down?"] > 0 then
391 counters["@[move down] is down"] = 0
392 self:on_is_move_down_down(counters)
393 counters["@is [move down] down?"] = 0
394 return true
395 end
396 if counters["@is [move right] down?"] > 0 then
397 counters["@[move right] is down"] = 0
398 self:on_is_move_right_down(counters)
399 counters["@is [move right] down?"] = 0
400 return true
401 end
402 if counters["@shoot bullet"] > 0 then
403 self:on_shoot_bullet(counters)
404 counters["@shoot bullet"] = 0
405 return true
406 end
407 if counters["@move bullets"] > 0 then
408 self:on_move_bullets(counters)
409 counters["@move bullets"] = 0
410 return true
411 end
412 if counters["@delete out of bounds bullets"] > 0 then
413 self:on_delete_bullets(counters)
414 counters["@delete out of bounds bullets"] = 0
415 return true
416 end
417 if counters["@draw bullets"] > 0 then
418 self:on_draw_bullets(counters)
419 counters["@draw bullets"] = 0
420 return true
421 end
422 if counters["@update spawn timer"] > 0 then
423 counters["@spawn timer expired"] = 0
424 self:on_update_spawn_timer(counters)
425 counters["@update spawn timer"] = 0
426 return true
427 end
428 if counters["@make the timer faster"] > 0 then
429 self:on_make_the_timer_faster(counters)
430 counters["@make the timer faster"] = 0
431 return true
432 end
433 if counters["@reset timer"] > 0 then
434 self:on_reset_timer(counters)
435 counters["@reset timer"] = 0
436 return true
437 end
438 if counters["@draw zombies"] > 0 then
439 self:on_draw_zombies(counters)
440 counters["@draw zombies"] = 0
441 return true
442 end
443 if counters["@spawn a zombie"] > 0 then
444 self:on_spawn_a_zombie(counters)
445 counters["@spawn a zombie"] = 0
446 return true
447 end
448 if counters["@delete killed zombies"] > 0 then
449 self:on_delete_killed_zombies(counters)
450 counters["@delete killed zombies"] = 0
451 return true
452 end
453 if counters["@move zombies"] > 0 then
454 self:on_move_zombies(counters)
455 counters["@move zombies"] = 0
456 return true
457 end
458 if counters["@do bullet collisions"] > 0 then
459 self:on_do_bullet_collisions(counters)
460 counters["@do bullet collisions"] = 0
461 return true
462 end
463 if counters["@start polling"] > 0 then
464 self:on_start_polling(counters)
465 counters["@start polling"] = 0
466 return true
467 end
468 if counters["@poll input"] > 0 then
469 counters["@event keypressed"] = 0
470 counters["@event keyreleased"] = 0
471 counters["@event mousemoved"] = 0
472 counters["@event mousepressed"] = 0
473 counters["@no events left"] = 0
474 self:on_poll_input(counters)
475 counters["@poll input"] = 0
476 return true
477 end
478 if counters["@quit love"] > 0 then
479 counters["@exit code"] = 0
480 self:on_quit_love(counters)
481 counters["@quit love"] = 0
482 return true
483 end
484 if counters["@step timer"] > 0 then
485 self:on_step_timer(counters)
486 counters["@step timer"] = 0
487 return true
488 end
489 if counters["@clear screen"] > 0 then
490 self:on_clear_screen(counters)
491 counters["@clear screen"] = 0
492 return true
493 end
494 if counters["@present"] > 0 then
495 self:on_present(counters)
496 counters["@present"] = 0
497 return true
498 end
499 if counters["@sleep"] > 0 then
500 self:on_sleep(counters, counters["@ms"])
501 counters["@sleep"] = 0
502 counters["@ms"] = 0
503 return true
504 end
505 if counters["handling input"] > 0 and counters["@event mousepressed"] > 0 then
506 local acc = huge
507 acc = min(acc, counters["@event mousepressed"])
508 acc = min(acc, counters["handling input"])
509 counters["handling input"] = max(counters["handling input"] - acc, 0)
510 counters["@event mousepressed"] = max(counters["@event mousepressed"] - acc, 0)
511 counters["shoot bullet"] = counters["shoot bullet"] + acc * 1
512 return true
513 end
514 if counters["shoot bullet"] > 0 then
515 local acc = counters["shoot bullet"]
516 counters["shoot bullet"] = max(counters["shoot bullet"] - acc, 0)
517 counters["@shoot bullet"] = counters["@shoot bullet"] + acc * 1
518 return true
519 end
520 if counters["drawing scene"] > 0 then
521 local acc = counters["drawing scene"]
522 counters["drawing scene"] = max(counters["drawing scene"] - acc, 0)
523 counters["@print fps"] = counters["@print fps"] + acc * 1
524 counters["draw zombies"] = counters["draw zombies"] + acc * 1
525 counters["draw player"] = counters["draw player"] + acc * 1
526 counters["draw bullets"] = counters["draw bullets"] + acc * 1
527 return true
528 end
529 if counters["draw player"] > 0 then
530 local acc = counters["draw player"]
531 counters["draw player"] = max(counters["draw player"] - acc, 0)
532 counters["@draw player"] = counters["@draw player"] + acc * 1
533 return true
534 end
535 if counters["draw bullets"] > 0 then
536 local acc = counters["draw bullets"]
537 counters["draw bullets"] = max(counters["draw bullets"] - acc, 0)
538 counters["@draw bullets"] = counters["@draw bullets"] + acc * 1
539 return true
540 end
541 if counters["draw zombies"] > 0 then
542 local acc = counters["draw zombies"]
543 counters["draw zombies"] = max(counters["draw zombies"] - acc, 0)
544 counters["@draw zombies"] = counters["@draw zombies"] + acc * 1
545 return true
546 end
547 if counters["updating scene"] > 0 then
548 local acc = counters["updating scene"]
549 counters["updating scene"] = max(counters["updating scene"] - acc, 0)
550 counters["move bullets"] = counters["move bullets"] + acc * 1
551 counters["move player"] = counters["move player"] + acc * 1
552 counters["check for collisions"] = counters["check for collisions"] + acc * 1
553 counters["sweep deleted entities"] = counters["sweep deleted entities"] + acc * 1
554 counters["update spawn timer"] = counters["update spawn timer"] + acc * 1
555 counters["move zombies"] = counters["move zombies"] + acc * 1
556 return true
557 end
558 if counters["move player"] > 0 then
559 local acc = counters["move player"]
560 counters["move player"] = max(counters["move player"] - acc, 0)
561 counters["@is [move right] down?"] = counters["@is [move right] down?"] + acc * 1
562 counters["@is [move up] down?"] = counters["@is [move up] down?"] + acc * 1
563 counters["@is [move left] down?"] = counters["@is [move left] down?"] + acc * 1
564 counters["moving player"] = counters["moving player"] + acc * 1
565 counters["@is [move down] down?"] = counters["@is [move down] down?"] + acc * 1
566 return true
567 end
568 if counters["moving player"] > 0 and counters["@[move up] is down"] > 0 then
569 local acc = huge
570 acc = min(acc, counters["moving player"])
571 acc = min(acc, counters["@[move up] is down"])
572 counters["moving player"] = max(counters["moving player"] - acc, 0)
573 counters["@[move up] is down"] = max(counters["@[move up] is down"] - acc, 0)
574 counters["moving player"] = counters["moving player"] + acc * 1
575 counters["@dir up"] = counters["@dir up"] + acc * 1
576 return true
577 end
578 if counters["moving player"] > 0 and counters["@[move left] is down"] > 0 then
579 local acc = huge
580 acc = min(acc, counters["moving player"])
581 acc = min(acc, counters["@[move left] is down"])
582 counters["moving player"] = max(counters["moving player"] - acc, 0)
583 counters["@[move left] is down"] = max(counters["@[move left] is down"] - acc, 0)
584 counters["@dir left"] = counters["@dir left"] + acc * 1
585 counters["moving player"] = counters["moving player"] + acc * 1
586 return true
587 end
588 if counters["moving player"] > 0 and counters["@[move down] is down"] > 0 then
589 local acc = huge
590 acc = min(acc, counters["moving player"])
591 acc = min(acc, counters["@[move down] is down"])
592 counters["moving player"] = max(counters["moving player"] - acc, 0)
593 counters["@[move down] is down"] = max(counters["@[move down] is down"] - acc, 0)
594 counters["moving player"] = counters["moving player"] + acc * 1
595 counters["@dir down"] = counters["@dir down"] + acc * 1
596 return true
597 end
598 if counters["moving player"] > 0 and counters["@[move right] is down"] > 0 then
599 local acc = huge
600 acc = min(acc, counters["moving player"])
601 acc = min(acc, counters["@[move right] is down"])
602 counters["moving player"] = max(counters["moving player"] - acc, 0)
603 counters["@[move right] is down"] = max(counters["@[move right] is down"] - acc, 0)
604 counters["moving player"] = counters["moving player"] + acc * 1
605 counters["@dir right"] = counters["@dir right"] + acc * 1
606 return true
607 end
608 if counters["@dir left"] > 0 and counters["@dir right"] > 0 then
609 local acc = huge
610 acc = min(acc, counters["@dir left"])
611 acc = min(acc, counters["@dir right"])
612 counters["@dir left"] = max(counters["@dir left"] - acc, 0)
613 counters["@dir right"] = max(counters["@dir right"] - acc, 0)
614 return true
615 end
616 if counters["@dir down"] > 0 and counters["@dir up"] > 0 then
617 local acc = huge
618 acc = min(acc, counters["@dir up"])
619 acc = min(acc, counters["@dir down"])
620 counters["@dir down"] = max(counters["@dir down"] - acc, 0)
621 counters["@dir up"] = max(counters["@dir up"] - acc, 0)
622 return true
623 end
624 if counters["moving player"] > 0 then
625 local acc = counters["moving player"]
626 counters["moving player"] = max(counters["moving player"] - acc, 0)
627 counters["@move player"] = counters["@move player"] + acc * 1
628 return true
629 end
630 if counters["move bullets"] > 0 then
631 local acc = counters["move bullets"]
632 counters["move bullets"] = max(counters["move bullets"] - acc, 0)
633 counters["@move bullets"] = counters["@move bullets"] + acc * 1
634 return true
635 end
636 if counters["move zombies"] > 0 then
637 local acc = counters["move zombies"]
638 counters["move zombies"] = max(counters["move zombies"] - acc, 0)
639 counters["@move zombies"] = counters["@move zombies"] + acc * 1
640 return true
641 end
642 if counters["check for collisions"] > 0 then
643 local acc = counters["check for collisions"]
644 counters["check for collisions"] = max(counters["check for collisions"] - acc, 0)
645 counters["check for player hit by zombie"] = counters["check for player hit by zombie"] + acc * 1
646 counters["check for bullet hitting zombie"] = counters["check for bullet hitting zombie"] + acc * 1
647 return true
648 end
649 if counters["check for player hit by zombie"] > 0 then
650 local acc = counters["check for player hit by zombie"]
651 counters["check for player hit by zombie"] = max(counters["check for player hit by zombie"] - acc, 0)
652 counters["@do player collisions"] = counters["@do player collisions"] + acc * 1
653 return true
654 end
655 if counters["check for bullet hitting zombie"] > 0 then
656 local acc = counters["check for bullet hitting zombie"]
657 counters["check for bullet hitting zombie"] = max(counters["check for bullet hitting zombie"] - acc, 0)
658 counters["@do bullet collisions"] = counters["@do bullet collisions"] + acc * 1
659 return true
660 end
661 if counters["update spawn timer"] > 0 then
662 local acc = counters["update spawn timer"]
663 counters["update spawn timer"] = max(counters["update spawn timer"] - acc, 0)
664 counters["@update spawn timer"] = counters["@update spawn timer"] + acc * 1
665 return true
666 end
667 if counters["@spawn timer expired"] > 0 then
668 local acc = counters["@spawn timer expired"]
669 counters["@spawn timer expired"] = max(counters["@spawn timer expired"] - acc, 0)
670 counters["make the timer faster"] = counters["make the timer faster"] + acc * 1
671 counters["spawn a zombie"] = counters["spawn a zombie"] + acc * 1
672 counters["reset timer"] = counters["reset timer"] + acc * 1
673 return true
674 end
675 if counters["spawn a zombie"] > 0 then
676 local acc = counters["spawn a zombie"]
677 counters["spawn a zombie"] = max(counters["spawn a zombie"] - acc, 0)
678 counters["@spawn a zombie"] = counters["@spawn a zombie"] + acc * 1
679 return true
680 end
681 if counters["make the timer faster"] > 0 then
682 local acc = counters["make the timer faster"]
683 counters["make the timer faster"] = max(counters["make the timer faster"] - acc, 0)
684 counters["@make the timer faster"] = counters["@make the timer faster"] + acc * 1
685 return true
686 end
687 if counters["reset timer"] > 0 then
688 local acc = counters["reset timer"]
689 counters["reset timer"] = max(counters["reset timer"] - acc, 0)
690 counters["@reset timer"] = counters["@reset timer"] + acc * 1
691 return true
692 end
693 if counters["sweep deleted entities"] > 0 then
694 local acc = counters["sweep deleted entities"]
695 counters["sweep deleted entities"] = max(counters["sweep deleted entities"] - acc, 0)
696 counters["@delete out of bounds bullets"] = counters["@delete out of bounds bullets"] + acc * 1
697 counters["@delete killed zombies"] = counters["@delete killed zombies"] + acc * 1
698 return true
699 end
700 if counters["handling input"] > 0 then
701 local acc = counters["handling input"]
702 counters["handling input"] = max(counters["handling input"] - acc, 0)
703 return true
704 end
705 if counters["updating scene"] > 0 then
706 local acc = counters["updating scene"]
707 counters["updating scene"] = max(counters["updating scene"] - acc, 0)
708 return true
709 end
710 if counters["drawing scene"] > 0 then
711 local acc = counters["drawing scene"]
712 counters["drawing scene"] = max(counters["drawing scene"] - acc, 0)
713 return true
714 end
715 if counters["run main loop"] > 0 then
716 local acc = counters["run main loop"]
717 counters["run main loop"] = max(counters["run main loop"] - acc, 0)
718 counters["poll input"] = counters["poll input"] + acc * 1
719 counters["run current frame"] = counters["run current frame"] + acc * 1
720 counters["start polling inputs"] = counters["start polling inputs"] + acc * 1
721 counters["handle input"] = counters["handle input"] + acc * 1
722 return true
723 end
724 if counters["start polling inputs"] > 0 then
725 local acc = counters["start polling inputs"]
726 counters["start polling inputs"] = max(counters["start polling inputs"] - acc, 0)
727 counters["@start polling"] = counters["@start polling"] + acc * 1
728 return true
729 end
730 if counters["poll input"] > 0 then
731 local acc = counters["poll input"]
732 counters["poll input"] = max(counters["poll input"] - acc, 0)
733 counters["@poll input"] = counters["@poll input"] + acc * 1
734 return true
735 end
736 if counters["handle input"] > 0 and counters["@no events left"] > 0 then
737 local acc = huge
738 acc = min(acc, counters["@no events left"])
739 acc = min(acc, counters["handle input"])
740 counters["handle input"] = max(counters["handle input"] - acc, 0)
741 counters["@no events left"] = max(counters["@no events left"] - acc, 0)
742 return true
743 end
744 if counters["handle input"] > 0 then
745 local acc = counters["handle input"]
746 counters["handle input"] = max(counters["handle input"] - acc, 0)
747 counters["poll input"] = counters["poll input"] + acc * 1
748 counters["handling input"] = counters["handling input"] + acc * 1
749 counters["handle input"] = counters["handle input"] + acc * 1
750 return true
751 end
752 if counters["run current frame"] > 0 and counters["@event quit"] > 0 then
753 local acc = huge
754 acc = min(acc, counters["@event quit"])
755 acc = min(acc, counters["run current frame"])
756 counters["run current frame"] = max(counters["run current frame"] - acc, 0)
757 counters["@event quit"] = max(counters["@event quit"] - acc, 0)
758 counters["@quit love"] = counters["@quit love"] + acc * 1
759 return true
760 end
761 if counters["run current frame"] > 0 then
762 local acc = counters["run current frame"]
763 counters["run current frame"] = max(counters["run current frame"] - acc, 0)
764 counters["present current frame"] = counters["present current frame"] + acc * 1
765 counters["sleep for 1ms"] = counters["sleep for 1ms"] + acc * 1
766 counters["next cycle"] = counters["next cycle"] + acc * 1
767 counters["step timer"] = counters["step timer"] + acc * 1
768 counters["clear the screen"] = counters["clear the screen"] + acc * 1
769 counters["update scene state"] = counters["update scene state"] + acc * 1
770 counters["draw scene"] = counters["draw scene"] + acc * 1
771 return true
772 end
773 if counters["step timer"] > 0 then
774 local acc = counters["step timer"]
775 counters["step timer"] = max(counters["step timer"] - acc, 0)
776 counters["@step timer"] = counters["@step timer"] + acc * 1
777 return true
778 end
779 if counters["clear the screen"] > 0 then
780 local acc = counters["clear the screen"]
781 counters["clear the screen"] = max(counters["clear the screen"] - acc, 0)
782 counters["@clear screen"] = counters["@clear screen"] + acc * 1
783 return true
784 end
785 if counters["update scene state"] > 0 then
786 local acc = counters["update scene state"]
787 counters["update scene state"] = max(counters["update scene state"] - acc, 0)
788 counters["updating scene"] = counters["updating scene"] + acc * 1
789 return true
790 end
791 if counters["draw scene"] > 0 then
792 local acc = counters["draw scene"]
793 counters["draw scene"] = max(counters["draw scene"] - acc, 0)
794 counters["drawing scene"] = counters["drawing scene"] + acc * 1
795 return true
796 end
797 if counters["present current frame"] > 0 then
798 local acc = counters["present current frame"]
799 counters["present current frame"] = max(counters["present current frame"] - acc, 0)
800 counters["@present"] = counters["@present"] + acc * 1
801 return true
802 end
803 if counters["sleep for 1ms"] > 0 then
804 local acc = counters["sleep for 1ms"]
805 counters["sleep for 1ms"] = max(counters["sleep for 1ms"] - acc, 0)
806 counters["@ms"] = counters["@ms"] + acc * 1
807 return true
808 end
809 if counters["next cycle"] > 0 then
810 local acc = counters["next cycle"]
811 counters["next cycle"] = max(counters["next cycle"] - acc, 0)
812 counters["run main loop"] = counters["run main loop"] + acc * 1
813 return true
814 end
815 return false
816end
817
818function machine:run()
819 local counters = self.counters
820 while match(self, counters) do end
821end
822
823return machine