big batch of changes
[chaz/yoink] / data / scenes / Classic.lua
1
2 -- Scene: Classic Yoink
3 -- created by Neil Carter
4 -- converted to Lua by Charles McGarvey
5
6 -- Scene API:
7 --
8 -- Functions:
9 -- SetBounds(point1, point2)
10 -- ResetTransform()
11 -- Translate(x, y, z)
12 -- Scale(x, y, z) or Scale(xyz)
13 -- Rotate(axis, degree) or Rotate(x, y, z)
14 -- SetTexture(name)
15 -- DrawTilemap({width = $num, [surface = TOP | LEFT | RIGHT], tiles})
16 -- DrawTile(tile, [u_scale])
17 --
18 -- Globals:
19 -- detail - level of detail of the scene (HIGH, MEDIUM, or LOW)
20
21
22 SetBounds({-5, 0, -6}, {45, 15, 7})
23
24
25 -- Left end tower block
26 -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27
28 -- Front
29
30 ResetTransform()
31 Translate(-5, 0, 5)
32 SetTexture("TowerBlock1")
33 DrawTilemap({
34 width = 5,
35 2, 2, 2, 2, 2,
36 1, 0, 0, 1, 0,
37 1, 0, 0, 1, 0,
38 1, 0, 0, 1, 0,
39 1, 0, 0, 1, 0,
40 1, 0, 0, 1, 0,
41 1, 0, 0, 1, 0,
42 1, 0, 0, 1, 0,
43 1, 0, 0, 1, 0,
44 1, 0, 0, 1, 0,
45 1, 0, 0, 1, 0,
46 1, 0, 0, 1, 0,
47 1, 0, 0, 1, 0,
48 1, 0, 0, 1, 0,
49 4, 4, 4, 4, 4})
50
51 -- Right side
52
53 ResetTransform()
54 Rotate(Y, 90)
55 Translate(0, 0, 5)
56 DrawTilemap({
57 width = 5,
58 surface = RIGHT,
59 2, 2, 2, 2, 2,
60 0, 0, 0, 0, 0,
61 0, 0, 0, 0, 0,
62 0, 0, 0, 0, 0,
63 0, 0, 0, 0, 0,
64 0, 0, 0, 0, 0,
65 0, 0, 0, 0, 0,
66 0, 0, 0, 0, 0,
67 0, 0, 0, 0, 0,
68 0, 0, 0, 0, 0,
69 0, 0, 0, 0, 0,
70 0, 0, 0, 0, 0,
71 0, 0, 0, 0, 0,
72 0, 0, 0, 0, 6,
73 4, 5, 5, 5, 4})
74
75 -- Top
76
77 ResetTransform()
78 Rotate(X, 90)
79 Translate(-5, 15, 0)
80 DrawTilemap({
81 width = 5,
82 surface = TOP,
83 3, 3, 3, 3, 3,
84 3, 3, 3, 3, 3,
85 3, 3, 3, 3, 3,
86 3, 3, 3, 3, 3,
87 3, 3, 3, 3, 3})
88
89 -- Leftmost background tower block
90 -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
91
92 -- Front
93
94 if detail > LOW then
95 ResetTransform()
96 DrawTilemap({
97 width = 7,
98 2, 2, 2, 2, 2, 2, 2,
99 0, 1, 0, 0, 0, 1, 0,
100 0, 1, 0, 0, 0, 1, 0,
101 0, 1, 0, 0, 6, 1, 0,
102 0, 1, 0, 0, 0, 1, 0,
103 0, 1, 0, 0, 0, 1, 0,
104 0, 1, 0, 0, 0, 1, 0,
105 4, 4, 5, 5, 5, 4, 4})
106
107 -- Right side
108
109 ResetTransform()
110 Rotate(Y, 90)
111 Translate(7, 0, 0)
112 DrawTilemap({
113 width = 6,
114 2, 2, 2, 2, 2, 2,
115 0, 1, 0, 0, 1, 0,
116 0, 1, 0, 0, 1, 0,
117 0, 1, 0, 0, 1, 0,
118 0, 1, 0, 0, 1, 0,
119 0, 1, 0, 0, 1, 0,
120 0, 1, 0, 0, 1, 0,
121 4, 4, 4, 4, 4, 4})
122
123 -- Top
124
125 ResetTransform()
126 Rotate(X, 90)
127 Translate(-2, 8, -6)
128 DrawTilemap({
129 width = 9,
130 3, 3, 3, 3, 3, 3, 3, 3, 3,
131 3, 3, 3, 3, 3, 3, 3, 3, 3,
132 3, 3, 3, 3, 3, 3, 3, 3, 3,
133 3, 3, 3, 3, 3, 3, 3, 3, 3,
134 3, 3, 3, 3, 3, 3, 3, 3, 3,
135 3, 3, 3, 3, 3, 3, 3, 3, 3})
136 end
137
138 -- Foreground building with pitched roof
139 -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
140
141 -- Left wall
142
143 ResetTransform()
144 Rotate(Y, -90)
145 Translate(10, 0, 1)
146 SetTexture("Building")
147 DrawTilemap({
148 width = 4,
149 surface = LEFT,
150 -1, 9, 11, -1,
151 9, 10, 12, 11,
152 15, 7, 7, 16,
153 3, 5, 6, 4,
154 3, 6, 5, 4})
155
156 -- Right wall
157
158 ResetTransform()
159 Rotate(Y, -90)
160 Translate(13, 0, 1)
161 DrawTilemap({
162 width = 4,
163 surface = RIGHT,
164 -1, 9, 11, -1,
165 9, 10, 12, 11,
166 15, 7, 7, 16,
167 3, 5, 6, 4,
168 3, 8, 5, 4})
169
170 -- Front wall
171
172 ResetTransform()
173 Translate(10, 0, 5)
174 DrawTilemap({
175 width = 3,
176 15, 7, 16,
177 3, 5, 4,
178 3, 6, 4})
179
180 -- Pitched roof
181
182 ResetTransform()
183 Rotate(X, 135)
184 Scale(1, 1.5, 1.5)
185 Translate(10, 5, 3)
186 DrawTilemap({
187 width = 3,
188 13, 13, 13,
189 13, 13, 13})
190
191 -- Finial
192
193 ResetTransform()
194 Translate(10, 5, 3)
195 DrawTilemap({
196 width = 3,
197 18, 18, 18})
198
199 -- Cheaty invisible platform
200
201 ResetTransform()
202 Translate(10, 4, 3)
203 DrawTilemap({
204 width = 3,
205 surface = TOP,
206 -1, -1, -1})
207
208 -- The ground
209 -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
210
211 -- Courtyard
212
213 ResetTransform()
214 Rotate(X, 90)
215 Translate(-3, 0, 0)
216 SetTexture("Scenery")
217 DrawTilemap({
218 width = 13,
219 surface = TOP,
220 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
221 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
222 -1, -1, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1,
223 -1, -1, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1,
224 -1, -1, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1,
225 -1, -1, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1,
226 -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1})
227
228 -- Front grass
229
230 if detail > MEDIUM then
231 ResetTransform()
232 Scale(8, 1, 1)
233 Translate(1, -0.5, 5)
234 DrawTile({
235 2,
236 u_scale = 8})
237
238 -- Back grass
239
240 ResetTransform()
241 Scale(8, 1, 1)
242 Translate(1, -0.5, 1)
243 DrawTile({
244 2,
245 u_scale = 8
246 })
247
248 -- Left grass
249
250 ResetTransform()
251 Scale(4, 1, 1)
252 Rotate(Y, -90)
253 Translate(1, -0.5, 1)
254 DrawTile({
255 2,
256 u_scale = 4
257 })
258
259 -- Right grass
260
261 ResetTransform()
262 Scale(4, 1, 1)
263 Rotate(Y, -90)
264 Translate(9, -0.5, 1)
265 DrawTile({
266 2,
267 u_scale = 4
268 })
269
270 -- Fence behind house
271
272 ResetTransform()
273 Scale(11, 1, 1)
274 Translate(7, 0, 0)
275 DrawTile({
276 4,
277 u_scale = 11
278 })
279 end
280
281 -- Background building with pitched roof
282 -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
283
284 -- Front wall
285
286 if detail > LOW then
287 ResetTransform()
288 Translate(19, 0, 0)
289 SetTexture("Building")
290 DrawTilemap({
291 width = 4,
292 -1, 9, 11, -1,
293 9, 10, 12, 11,
294 15, 7, 7, 16,
295 3, 6, 5, 4,
296 3, 5, 6, 4,
297 3, 8, 5, 4})
298
299 -- Left wall
300
301 ResetTransform()
302 Rotate(Y, -90)
303 Translate(19, 0, -3)
304 DrawTilemap({
305 width = 3,
306 15, 1, 16,
307 3, 7, 4,
308 3, 5, 4,
309 3, 0, 4})
310
311 -- Right wall
312
313 ResetTransform()
314 Rotate(Y, -90)
315 Translate(23, 0, -3)
316 DrawTilemap({
317 width = 3,
318 15, 0, 16,
319 3, 7, 4,
320 3, 6, 4,
321 3, 2, 4})
322
323 -- Left pitched roof
324
325 ResetTransform()
326 Rotate(X, 135)
327 Scale(1, 1.5, 1.5)
328 Rotate(Y, -90)
329 Translate(21, 6, -3)
330 DrawTilemap({
331 width = 3,
332 13, 13, 13,
333 13, 13, 13})
334
335 -- Right pitched roof
336
337 ResetTransform()
338 Rotate(X, -135)
339 Scale(1, 1.5, 1.5)
340 Rotate(Y, -90)
341 Translate(21, 6, -3)
342 DrawTilemap({
343 width = 3,
344 13, 13, 13,
345 13, 13, 13})
346
347 -- Finial
348
349 ResetTransform()
350 Rotate(Y, -90)
351 Translate(21, 6, -3)
352 DrawTilemap({
353 width = 3,
354 18, 18, 18})
355 end
356
357 -- More ground to the right
358 -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
359
360 -- Ground under house
361
362 ResetTransform()
363 Rotate(X, 90)
364 Translate(10, 0, 0)
365 SetTexture("Scenery")
366 DrawTilemap({
367 width = 3,
368 surface = TOP,
369 1, 1, 1,
370 1, 1, 1,
371 -1, -1, -1,
372 -1, -1, -1,
373 -1, -1, -1,
374 -1, -1, -1,
375 1, 1, 1})
376
377 -- Left part of center courtyard
378
379 ResetTransform()
380 Rotate(X, 90)
381 Translate(13, 0, 0)
382 DrawTilemap({
383 width = 8,
384 surface = TOP,
385 1, 1, 1, 1, 1, 1, 1, 1,
386 1, 1, 1, 1, 1, 1, 1, 1,
387 1, 0, 0, 0, 0, 0, 0, 0,
388 1, 0, 0, 0, 0, 0, 1, 1,
389 0, 0, 0, 0, 0, 0, 1, 1,
390 1, 0, 0, 0, 0, 0, 0, 0,
391 1, 1, 1, 1, 1, 0, 0, 0})
392
393 -- Front grass
394
395 if detail > MEDIUM then
396 ResetTransform()
397 Scale(12, 1, 1)
398 Translate(14, -0.5, 5)
399 DrawTile({
400 2,
401 u_scale = 12
402 })
403
404 -- Back grass
405
406 ResetTransform()
407 Scale(4, 1, 1)
408 Translate(14, -0.5, 1)
409 DrawTile({
410 2,
411 u_scale = 4
412 })
413
414 -- Front grass next to door
415
416 ResetTransform()
417 Translate(13, -0.5, 3)
418 DrawTile({
419 2,
420 u_scale = 1
421 })
422
423 -- Back grass next to door
424
425 ResetTransform()
426 Translate(13, -0.5, 2)
427 DrawTile({
428 2,
429 u_scale = 1
430 })
431
432 -- Left grass
433
434 ResetTransform()
435 Rotate(Y, -90)
436 Translate(14, -0.5, 1)
437 DrawTilemap({
438 width = 4,
439 2, -1, 2, 2})
440
441 -- Grass left of house
442
443 ResetTransform()
444 Rotate(Y, -90)
445 Translate(18, -0.5, 0)
446 DrawTile({
447 2,
448 u_scale = 1
449 })
450
451 -- Grass right of house
452
453 ResetTransform()
454 Rotate(Y, -90)
455 Translate(24, -0.5, 0)
456 DrawTile({
457 2,
458 u_scale = 1
459 })
460
461 -- Front grass in center
462
463 ResetTransform()
464 Scale(4, 1, 1)
465 Translate(19, -0.5, 4)
466 DrawTile({
467 2,
468 u_scale = 4
469 })
470
471 -- Back grass in center
472
473 ResetTransform()
474 Scale(4, 1, 1)
475 Translate(19, -0.5, 2)
476 DrawTile({
477 2,
478 u_scale = 4
479 })
480
481 -- Left grass in center
482
483 ResetTransform()
484 Scale(2, 1, 1)
485 Rotate(Y, -90)
486 Translate(19, -0.5, 2)
487 DrawTile({
488 2,
489 u_scale = 2
490 })
491
492 -- Right grass in center
493
494 ResetTransform()
495 Scale(2, 1, 1)
496 Rotate(Y, -90)
497 Translate(23, -0.5, 2)
498 DrawTile({
499 2,
500 u_scale = 2
501 })
502 end
503
504 -- Right part of center courtyard
505
506 ResetTransform()
507 Rotate(X, 90)
508 Translate(21, 0, 0)
509 DrawTilemap({
510 width = 7,
511 surface = TOP,
512 1, 1, 1, 1, 1, 0, 0,
513 1, 1, 1, 1, 1, 0, 0,
514 0, 0, 0, 0, 0, 0, 0,
515 1, 1, 0, 0, 0, 0, 0,
516 1, 1, 0, 0, 0, 0, 0,
517 0, 0, 0, 0, 0, 0, 0,
518 0, 0, 0, 1, 1, 1, 1})
519
520 -- Fence to right of back house
521
522 if detail > MEDIUM then
523 ResetTransform()
524 Scale(4, 1, 1)
525 Translate(24, 0, 0)
526 DrawTile({
527 4,
528 u_scale = 4
529 })
530
531 -- Grass in front of fence
532
533 ResetTransform()
534 Scale(4, 1, 1)
535 Translate(24, -0.5, 1)
536 DrawTile({
537 2,
538 u_scale = 4
539 })
540
541 -- Grass to left of tower block
542
543 ResetTransform()
544 Scale(2, 1, 1)
545 Rotate(Y, -90)
546 Translate(26, -0.5, 5)
547 DrawTile({
548 2,
549 u_scale = 2
550 })
551
552 -- Grass to right of tower block
553
554 ResetTransform()
555 Scale(2, 1, 1)
556 Rotate(Y, -90)
557 Translate(35, -0.5, 5)
558 DrawTile({
559 2,
560 u_scale = 2
561 })
562
563 -- Next bit of grass
564
565 ResetTransform()
566 Scale(5, 1, 1)
567 Translate(35, -0.5, 5)
568 DrawTile({
569 2,
570 u_scale = 5
571 })
572
573 -- Back grass
574
575 ResetTransform()
576 Scale(6, 1, 1)
577 Translate(34, -0.5, 1)
578 DrawTile({
579 2,
580 u_scale = 6
581 })
582
583 -- Extra bit of back grass
584
585 ResetTransform()
586 Rotate(Y, -90)
587 Translate(34, -0.5, 0)
588 DrawTile({
589 2,
590 u_scale = 1
591 })
592 end
593
594 -- Ground around tower block
595
596 ResetTransform()
597 Rotate(X, 90)
598 Translate(28, 0, 4)
599 DrawTilemap({
600 width = 5,
601 surface = TOP,
602 0, 0, 0, 0, 0,
603 0, 0, 0, 0, 0,
604 0, 0, 0, 0, 0})
605
606 -- Rightmost ground
607
608 ResetTransform()
609 Rotate(X, 90)
610 Translate(33, 0, 0)
611 DrawTilemap({
612 width = 10,
613 surface = TOP,
614 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
615 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
616 0, 0, 0, 0, 0, 0, 0, -1, -1, -1,
617 0, 0, 0, 0, 0, 0, 0, -1, -1, -1,
618 0, 0, 0, 0, 0, 0, 0, -1, -1, -1,
619 0, 0, 0, 0, 0, 0, 0, -1, -1, -1,
620 0, 1, 1, 1, 1, 1, 1, -1, -1, -1})
621
622 -- Right foreground tower block
623 -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
624
625 -- Front
626
627 ResetTransform()
628 Translate(28, 0, 4)
629 SetTexture("TowerBlock1")
630 DrawTilemap({
631 width = 5,
632 2, 2, 2, 2, 2,
633 0, 0, 0, 0, 0,
634 0, 0, 0, 0, 6,
635 0, 0, 0, 0, 0,
636 0, 0, 0, 0, 0,
637 0, 0, 0, 6, 0,
638 4, 4, 4, 4, 4})
639
640 -- Right side
641
642 ResetTransform()
643 Rotate(Y, 90)
644 Translate(33, 0, 4)
645 DrawTilemap({
646 width = 6,
647 surface = RIGHT,
648 2, 2, 2, 2, 2, 2,
649 0, 1, 0, 0, 1, 0,
650 0, 1, 0, 0, 1, 0,
651 0, 1, 0, 0, 1, 0,
652 0, 1, 0, 0, 1, 0,
653 0, 1, 0, 0, 1, 0,
654 5, 4, 5, 5, 4, 5})
655
656 -- Left side
657
658 ResetTransform()
659 Rotate(Y, 90)
660 Translate(28, 0, 4)
661 DrawTilemap({
662 width = 6,
663 surface = LEFT,
664 2, 2, 2, 2, 2, 2,
665 0, 1, 6, 0, 1, 0,
666 0, 1, 0, 0, 1, 0,
667 0, 1, 0, 0, 1, 0,
668 0, 1, 0, 0, 1, 0,
669 0, 1, 0, 0, 1, 0,
670 5, 4, 5, 5, 4, 5})
671
672 -- Top
673
674 ResetTransform()
675 Rotate(X, 90)
676 Translate(28, 7, -2)
677 DrawTilemap({
678 width = 5,
679 surface = TOP,
680 3, 3, 3, 3, 3,
681 3, 3, 3, 3, 3,
682 3, 3, 3, 3, 3,
683 3, 3, 3, 3, 3,
684 3, 3, 3, 3, 3,
685 3, 3, 3, 3, 3})
686
687 -- Right end tower block
688 -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
689
690 -- Front
691
692 ResetTransform()
693 Translate(40, 0, 5)
694 DrawTilemap({
695 width = 5,
696 2, 2, 2, 2, 2,
697 0, 1, 0, 0, 1,
698 0, 1, 0, 0, 1,
699 0, 1, 0, 0, 1,
700 0, 1, 0, 0, 1,
701 6, 1, 0, 0, 1,
702 0, 1, 0, 0, 1,
703 0, 1, 0, 0, 1,
704 0, 1, 0, 0, 1,
705 0, 1, 0, 0, 1,
706 0, 1, 0, 0, 1,
707 6, 1, 0, 0, 1,
708 0, 1, 0, 0, 1,
709 0, 1, 0, 0, 1,
710 4, 4, 4, 4, 4})
711
712 -- Left side
713
714 ResetTransform()
715 Rotate(Y, 90)
716 Translate(40, 0, 5)
717 DrawTilemap({
718 width = 5,
719 surface = LEFT,
720 2, 2, 2, 2, 2,
721 6, 0, 0, 0, 0,
722 0, 0, 0, 0, 0,
723 0, 0, 0, 0, 0,
724 0, 0, 0, 6, 0,
725 0, 0, 0, 0, 0,
726 0, 0, 0, 0, 0,
727 0, 0, 6, 0, 0,
728 0, 0, 0, 0, 0,
729 0, 0, 0, 0, 0,
730 0, 0, 0, 0, 0,
731 0, 0, 0, 0, 0,
732 0, 0, 0, 0, 0,
733 0, 0, 0, 0, 0,
734 4, 5, 5, 5, 4})
735
736 -- Top
737
738 ResetTransform()
739 Rotate(X, 90)
740 Translate(40, 15, 0)
741 DrawTilemap({
742 width = 5,
743 surface = TOP,
744 3, 3, 3, 3, 3,
745 3, 3, 3, 3, 3,
746 3, 3, 3, 3, 3,
747 3, 3, 3, 3, 3,
748 3, 3, 3, 3, 3})
749
750 -- Background
751 -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
752
753 ResetTransform()
754 Translate(-0.3, -0.17, -28)
755 Scale(100, 50, 1)
756 SetTexture("BackgroundFar")
757 DrawTile()
758
759 Translate(0, 0, 5)
760 SetTexture("BackgroundNear")
761 DrawTile({
762 blend = detail > LOW and true or false
763 })
764
765 -- Trees
766 -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
767
768 SetTexture("Trees")
769
770 -- Left courtyard
771
772 if detail > LOW then
773 ResetTransform()
774 Scale(3)
775 Translate(7.75, -0.1, 0.5)
776 DrawTile(1)
777 end
778
779 -- Center courtyard
780
781 ResetTransform()
782 --Translate(610, -2.5, 85)
783 Scale(3)
784 Translate(19, -0.1, 2.5)
785 DrawTile(0)
786
787 ResetTransform()
788 Scale(3)
789 Translate(20.25, -0.1, 3.5)
790 DrawTile(1)
791
792 -- Right courtyard
793
794 if detail > LOW then
795 ResetTransform()
796 Scale(3)
797 Translate(34, -0.1, 0.25)
798 DrawTile(1)
799
800 ResetTransform()
801 Scale(3)
802 Translate(36, -0.1, -0.5)
803 DrawTile(0)
804
805 ResetTransform()
806 Scale(3)
807 Translate(37, -0.1, 0.75)
808 DrawTile(1)
809 end
810
811
812
813 function GetZCoord(x, y)
814 return 3
815 end
816
817
818 -- Functions:
819 -- DisplayText(text, seconds)
820 -- Yield(seconds)
821 -- SpawnItem(what, coords, timeout)
822 -- SpawnRandomItem(coords, timeout)
823 -- SpawnCharacter(what, coords, ai level)
824 -- SpawnHeroine(coords)
825 -- PlaySound(name)
826 -- PlayMusic(name)
827 -- BeginNewWave()
828
829 -- Events:
830 -- BadGuyDied(enemy)
831 -- PlayedDied(player)
832 -- SceneLoaded()
833
834 -- Globals:
835 -- numberOfBadGuys
836
837
838 -- Events
839 ---------
840
841 Event = {}
842
843 function Event:SceneLoaded()
844 SpawnHeroine({500, 500})
845 local waveNum = BeginNewWave()
846 PopulateScene(waveNum)
847 end
848
849 function Event:BadGuyDied(enemy)
850 if numberOfBadGuys == 0 then
851 local waveNum = BeginNewWave()
852 PopulateScene(waveNum)
853 end
854 if math.random() <= 0.2 then
855 SpawnRandomItem(enemy.position)
856 end
857 end
858
859
860 -- Helper functions
861 -------------------
862
863 function PopulateScene(waveNum)
864 -- spawn some robot troopers
865 local numBadGuys = math.random(3, 2 * waveNum)
866 for i = 0, numBadGuys do
867 SpawnCharacter("RobotTrooper", RandomSpawnPlace(), RandomSkillLevel())
868 end
869
870 -- spawn some alien warriors
871 if waveNum >= 10 then
872 numBadGuys = math.random(3, 2 * waveNum)
873 for i = 0, numBadGuys do
874 SpawnCharacter("AlienWarrior", RandomSpawnPlace(), RandomSkillLevel())
875 end
876 end
877
878 -- spawn some jetbots
879 if waveNum >= 20 then
880 numBadGuys = math.random(3, 2 * waveNum)
881 for i = 0, numBadGuys do
882 SpawnCharacter("Jetbot", RandomSpawnPlace(), RandomSkillLevel())
883 end
884 end
885 end
886
887 function RandomSpawnPlace()
888 return {500, 500}
889 end
890
891 function RandomSkillLevel()
892 return "dumb"
893 end
894
This page took 0.077564 seconds and 4 git commands to generate.