e8ba272faac8d7c8ad12808f8559d03440fc3aa1
[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 -- This draws nothing but creates a platform on the roof for walking.
201
202 ResetTransform()
203 Rotate(X, 90)
204 Translate(10, 5, 0)
205 DrawTilemap({
206 width = 3,
207 surface = TOP,
208 -1, -1, -1})
209
210 -- The ground
211 -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
212
213 -- Courtyard
214
215 ResetTransform()
216 Rotate(X, 90)
217 Translate(-3, 0, 0)
218 SetTexture("Scenery")
219 DrawTilemap({
220 width = 13,
221 surface = TOP,
222 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
223 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 1,
227 -1, -1, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1,
228 -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1})
229
230 -- Front grass
231
232 if detail > MEDIUM then
233 ResetTransform()
234 Scale(8, 1, 1)
235 Translate(1, -0.5, 5)
236 DrawTile({
237 2,
238 u_scale = 8})
239
240 -- Back grass
241
242 ResetTransform()
243 Scale(8, 1, 1)
244 Translate(1, -0.5, 1)
245 DrawTile({
246 2,
247 u_scale = 8
248 })
249
250 -- Left grass
251
252 ResetTransform()
253 Scale(4, 1, 1)
254 Rotate(Y, -90)
255 Translate(1, -0.5, 1)
256 DrawTile({
257 2,
258 u_scale = 4
259 })
260
261 -- Right grass
262
263 ResetTransform()
264 Scale(4, 1, 1)
265 Rotate(Y, -90)
266 Translate(9, -0.5, 1)
267 DrawTile({
268 2,
269 u_scale = 4
270 })
271
272 -- Fence behind house
273
274 ResetTransform()
275 Scale(11, 1, 1)
276 Translate(7, 0, 0)
277 DrawTile({
278 4,
279 u_scale = 11
280 })
281 end
282
283 -- Background building with pitched roof
284 -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
285
286 -- Front wall
287
288 if detail > LOW then
289 ResetTransform()
290 Translate(19, 0, 0)
291 SetTexture("Building")
292 DrawTilemap({
293 width = 4,
294 -1, 9, 11, -1,
295 9, 10, 12, 11,
296 15, 7, 7, 16,
297 3, 6, 5, 4,
298 3, 5, 6, 4,
299 3, 8, 5, 4})
300
301 -- Left wall
302
303 ResetTransform()
304 Rotate(Y, -90)
305 Translate(19, 0, -3)
306 DrawTilemap({
307 width = 3,
308 15, 1, 16,
309 3, 7, 4,
310 3, 5, 4,
311 3, 0, 4})
312
313 -- Right wall
314
315 ResetTransform()
316 Rotate(Y, -90)
317 Translate(23, 0, -3)
318 DrawTilemap({
319 width = 3,
320 15, 0, 16,
321 3, 7, 4,
322 3, 6, 4,
323 3, 2, 4})
324
325 -- Left pitched roof
326
327 ResetTransform()
328 Rotate(X, 135)
329 Scale(1, 1.5, 1.5)
330 Rotate(Y, -90)
331 Translate(21, 6, -3)
332 DrawTilemap({
333 width = 3,
334 13, 13, 13,
335 13, 13, 13})
336
337 -- Right pitched roof
338
339 ResetTransform()
340 Rotate(X, -135)
341 Scale(1, 1.5, 1.5)
342 Rotate(Y, -90)
343 Translate(21, 6, -3)
344 DrawTilemap({
345 width = 3,
346 13, 13, 13,
347 13, 13, 13})
348
349 -- Finial
350
351 ResetTransform()
352 Rotate(Y, -90)
353 Translate(21, 6, -3)
354 DrawTilemap({
355 width = 3,
356 18, 18, 18})
357 end
358
359 -- More ground to the right
360 -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
361
362 -- Ground under house
363
364 ResetTransform()
365 Rotate(X, 90)
366 Translate(10, 0, 0)
367 SetTexture("Scenery")
368 DrawTilemap({
369 width = 3,
370 surface = TOP,
371 1, 1, 1,
372 1, 1, 1,
373 -1, -1, -1,
374 -1, -1, -1,
375 -1, -1, -1,
376 -1, -1, -1,
377 1, 1, 1})
378
379 -- Left part of center courtyard
380
381 ResetTransform()
382 Rotate(X, 90)
383 Translate(13, 0, 0)
384 DrawTilemap({
385 width = 8,
386 surface = TOP,
387 1, 1, 1, 1, 1, 1, 1, 1,
388 1, 1, 1, 1, 1, 1, 1, 1,
389 1, 0, 0, 0, 0, 0, 0, 0,
390 1, 0, 0, 0, 0, 0, 1, 1,
391 0, 0, 0, 0, 0, 0, 1, 1,
392 1, 0, 0, 0, 0, 0, 0, 0,
393 1, 1, 1, 1, 1, 0, 0, 0})
394
395 -- Front grass
396
397 if detail > MEDIUM then
398 ResetTransform()
399 Scale(12, 1, 1)
400 Translate(14, -0.5, 5)
401 DrawTile({
402 2,
403 u_scale = 12
404 })
405
406 -- Back grass
407
408 ResetTransform()
409 Scale(4, 1, 1)
410 Translate(14, -0.5, 1)
411 DrawTile({
412 2,
413 u_scale = 4
414 })
415
416 -- Front grass next to door
417
418 ResetTransform()
419 Translate(13, -0.5, 3)
420 DrawTile({
421 2,
422 u_scale = 1
423 })
424
425 -- Back grass next to door
426
427 ResetTransform()
428 Translate(13, -0.5, 2)
429 DrawTile({
430 2,
431 u_scale = 1
432 })
433
434 -- Left grass
435
436 ResetTransform()
437 Rotate(Y, -90)
438 Translate(14, -0.5, 1)
439 DrawTilemap({
440 width = 4,
441 2, -1, 2, 2})
442
443 -- Grass left of house
444
445 ResetTransform()
446 Rotate(Y, -90)
447 Translate(18, -0.5, 0)
448 DrawTile({
449 2,
450 u_scale = 1
451 })
452
453 -- Grass right of house
454
455 ResetTransform()
456 Rotate(Y, -90)
457 Translate(24, -0.5, 0)
458 DrawTile({
459 2,
460 u_scale = 1
461 })
462
463 -- Front grass in center
464
465 ResetTransform()
466 Scale(4, 1, 1)
467 Translate(19, -0.5, 4)
468 DrawTile({
469 2,
470 u_scale = 4
471 })
472
473 -- Back grass in center
474
475 ResetTransform()
476 Scale(4, 1, 1)
477 Translate(19, -0.5, 2)
478 DrawTile({
479 2,
480 u_scale = 4
481 })
482
483 -- Left grass in center
484
485 ResetTransform()
486 Scale(2, 1, 1)
487 Rotate(Y, -90)
488 Translate(19, -0.5, 2)
489 DrawTile({
490 2,
491 u_scale = 2
492 })
493
494 -- Right grass in center
495
496 ResetTransform()
497 Scale(2, 1, 1)
498 Rotate(Y, -90)
499 Translate(23, -0.5, 2)
500 DrawTile({
501 2,
502 u_scale = 2
503 })
504 end
505
506 -- Right part of center courtyard
507
508 ResetTransform()
509 Rotate(X, 90)
510 Translate(21, 0, 0)
511 DrawTilemap({
512 width = 7,
513 surface = TOP,
514 1, 1, 1, 1, 1, 0, 0,
515 1, 1, 1, 1, 1, 0, 0,
516 0, 0, 0, 0, 0, 0, 0,
517 1, 1, 0, 0, 0, 0, 0,
518 1, 1, 0, 0, 0, 0, 0,
519 0, 0, 0, 0, 0, 0, 0,
520 0, 0, 0, 1, 1, 1, 1})
521
522 -- Fence to right of back house
523
524 if detail > MEDIUM then
525 ResetTransform()
526 Scale(4, 1, 1)
527 Translate(24, 0, 0)
528 DrawTile({
529 4,
530 u_scale = 4
531 })
532
533 -- Grass in front of fence
534
535 ResetTransform()
536 Scale(4, 1, 1)
537 Translate(24, -0.5, 1)
538 DrawTile({
539 2,
540 u_scale = 4
541 })
542
543 -- Grass to left of tower block
544
545 ResetTransform()
546 Scale(2, 1, 1)
547 Rotate(Y, -90)
548 Translate(26, -0.5, 5)
549 DrawTile({
550 2,
551 u_scale = 2
552 })
553
554 -- Grass to right of tower block
555
556 ResetTransform()
557 Scale(2, 1, 1)
558 Rotate(Y, -90)
559 Translate(35, -0.5, 5)
560 DrawTile({
561 2,
562 u_scale = 2
563 })
564
565 -- Next bit of grass
566
567 ResetTransform()
568 Scale(5, 1, 1)
569 Translate(35, -0.5, 5)
570 DrawTile({
571 2,
572 u_scale = 5
573 })
574
575 -- Back grass
576
577 ResetTransform()
578 Scale(6, 1, 1)
579 Translate(34, -0.5, 1)
580 DrawTile({
581 2,
582 u_scale = 6
583 })
584
585 -- Extra bit of back grass
586
587 ResetTransform()
588 Rotate(Y, -90)
589 Translate(34, -0.5, 0)
590 DrawTile({
591 2,
592 u_scale = 1
593 })
594 end
595
596 -- Ground around tower block
597
598 ResetTransform()
599 Rotate(X, 90)
600 Translate(28, 0, 4)
601 DrawTilemap({
602 width = 5,
603 surface = TOP,
604 0, 0, 0, 0, 0,
605 0, 0, 0, 0, 0,
606 0, 0, 0, 0, 0})
607
608 -- Rightmost ground
609
610 ResetTransform()
611 Rotate(X, 90)
612 Translate(33, 0, 0)
613 DrawTilemap({
614 width = 10,
615 surface = TOP,
616 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
617 0, 0, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, -1, -1, -1,
621 0, 0, 0, 0, 0, 0, 0, -1, -1, -1,
622 0, 1, 1, 1, 1, 1, 1, -1, -1, -1})
623
624 -- Right foreground tower block
625 -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
626
627 -- Front
628
629 ResetTransform()
630 Translate(28, 0, 4)
631 SetTexture("TowerBlock1")
632 DrawTilemap({
633 width = 5,
634 2, 2, 2, 2, 2,
635 0, 0, 0, 0, 0,
636 0, 0, 0, 0, 6,
637 0, 0, 0, 0, 0,
638 0, 0, 0, 0, 0,
639 0, 0, 0, 6, 0,
640 4, 4, 4, 4, 4})
641
642 -- Right side
643
644 ResetTransform()
645 Rotate(Y, 90)
646 Translate(33, 0, 4)
647 DrawTilemap({
648 width = 6,
649 surface = RIGHT,
650 2, 2, 2, 2, 2, 2,
651 0, 1, 0, 0, 1, 0,
652 0, 1, 0, 0, 1, 0,
653 0, 1, 0, 0, 1, 0,
654 0, 1, 0, 0, 1, 0,
655 0, 1, 0, 0, 1, 0,
656 5, 4, 5, 5, 4, 5})
657
658 -- Left side
659
660 ResetTransform()
661 Rotate(Y, 90)
662 Translate(28, 0, 4)
663 DrawTilemap({
664 width = 6,
665 surface = LEFT,
666 2, 2, 2, 2, 2, 2,
667 0, 1, 6, 0, 1, 0,
668 0, 1, 0, 0, 1, 0,
669 0, 1, 0, 0, 1, 0,
670 0, 1, 0, 0, 1, 0,
671 0, 1, 0, 0, 1, 0,
672 5, 4, 5, 5, 4, 5})
673
674 -- Top
675
676 ResetTransform()
677 Rotate(X, 90)
678 Translate(28, 7, -2)
679 DrawTilemap({
680 width = 5,
681 surface = TOP,
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 3, 3, 3, 3, 3,
687 3, 3, 3, 3, 3})
688
689 -- Right end tower block
690 -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
691
692 -- Front
693
694 ResetTransform()
695 Translate(40, 0, 5)
696 DrawTilemap({
697 width = 5,
698 2, 2, 2, 2, 2,
699 0, 1, 0, 0, 1,
700 0, 1, 0, 0, 1,
701 0, 1, 0, 0, 1,
702 0, 1, 0, 0, 1,
703 6, 1, 0, 0, 1,
704 0, 1, 0, 0, 1,
705 0, 1, 0, 0, 1,
706 0, 1, 0, 0, 1,
707 0, 1, 0, 0, 1,
708 0, 1, 0, 0, 1,
709 6, 1, 0, 0, 1,
710 0, 1, 0, 0, 1,
711 0, 1, 0, 0, 1,
712 4, 4, 4, 4, 4})
713
714 -- Left side
715
716 ResetTransform()
717 Rotate(Y, 90)
718 Translate(40, 0, 5)
719 DrawTilemap({
720 width = 5,
721 surface = LEFT,
722 2, 2, 2, 2, 2,
723 6, 0, 0, 0, 0,
724 0, 0, 0, 0, 0,
725 0, 0, 0, 0, 0,
726 0, 0, 0, 6, 0,
727 0, 0, 0, 0, 0,
728 0, 0, 0, 0, 0,
729 0, 0, 6, 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 0, 0, 0, 0, 0,
735 0, 0, 0, 0, 0,
736 4, 5, 5, 5, 4})
737
738 -- Top
739
740 ResetTransform()
741 Rotate(X, 90)
742 Translate(40, 15, 0)
743 DrawTilemap({
744 width = 5,
745 surface = TOP,
746 3, 3, 3, 3, 3,
747 3, 3, 3, 3, 3,
748 3, 3, 3, 3, 3,
749 3, 3, 3, 3, 3,
750 3, 3, 3, 3, 3})
751
752 -- Background
753 -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
754
755 ResetTransform()
756 Translate(-0.32, -0.28, -24)
757 Scale(105, 52, 1)
758 SetTexture("BackgroundFar")
759 DrawTile()
760
761 Translate(0, 0, 5)
762 SetTexture("BackgroundNear")
763 DrawTile({
764 blend = detail > LOW and true or false
765 })
766
767 -- Trees
768 -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
769
770 SetTexture("Trees")
771
772 -- Left courtyard
773
774 if detail > LOW then
775 ResetTransform()
776 Scale(3)
777 Translate(7.75, -0.1, 0.5)
778 DrawTile(1)
779 end
780
781 -- Center courtyard
782
783 ResetTransform()
784 --Translate(610, -2.5, 85)
785 Scale(3)
786 Translate(19, -0.1, 2.5)
787 DrawTile(0)
788
789 ResetTransform()
790 Scale(3)
791 Translate(20.25, -0.1, 3.5)
792 DrawTile(1)
793
794 -- Right courtyard
795
796 if detail > LOW then
797 ResetTransform()
798 Scale(3)
799 Translate(34, -0.1, 0.25)
800 DrawTile(1)
801
802 ResetTransform()
803 Scale(3)
804 Translate(36, -0.1, -0.5)
805 DrawTile(0)
806
807 ResetTransform()
808 Scale(3)
809 Translate(37, -0.1, 0.75)
810 DrawTile(1)
811 end
812
813
814
815 function GetZCoord(x, y)
816 return 3.00001
817 end
818
819
820 -- Functions:
821 -- DisplayText(text, seconds)
822 -- Yield(seconds)
823 -- SpawnItem(what, coords, timeout)
824 -- SpawnRandomItem(coords, timeout)
825 -- SpawnCharacter(what, coords, ai level)
826 -- SpawnHeroine(coords)
827 -- PlaySound(name)
828 -- PlayMusic(name)
829 -- BeginNewWave()
830
831 -- Events:
832 -- BadGuyDied(enemy)
833 -- PlayedDied(player)
834 -- SceneLoaded()
835
836 -- Globals:
837 -- numberOfBadGuys
838
839
840 -- Events
841 ---------
842
843 Event = {}
844
845 function Event:SceneLoaded()
846 SpawnHeroine({500, 500})
847 local waveNum = BeginNewWave()
848 PopulateScene(waveNum)
849 end
850
851 function Event:BadGuyDied(enemy)
852 if numberOfBadGuys == 0 then
853 local waveNum = BeginNewWave()
854 PopulateScene(waveNum)
855 end
856 if math.random() <= 0.2 then
857 SpawnRandomItem(enemy.position)
858 end
859 end
860
861
862 -- Helper functions
863 -------------------
864
865 function PopulateScene(waveNum)
866 -- spawn some robot troopers
867 local numBadGuys = math.random(3, 2 * waveNum)
868 for i = 0, numBadGuys do
869 SpawnCharacter("RobotTrooper", RandomSpawnPlace(), RandomSkillLevel())
870 end
871
872 -- spawn some alien warriors
873 if waveNum >= 10 then
874 numBadGuys = math.random(3, 2 * waveNum)
875 for i = 0, numBadGuys do
876 SpawnCharacter("AlienWarrior", RandomSpawnPlace(), RandomSkillLevel())
877 end
878 end
879
880 -- spawn some jetbots
881 if waveNum >= 20 then
882 numBadGuys = math.random(3, 2 * waveNum)
883 for i = 0, numBadGuys do
884 SpawnCharacter("Jetbot", RandomSpawnPlace(), RandomSkillLevel())
885 end
886 end
887 end
888
889 function RandomSpawnPlace()
890 return {500, 500}
891 end
892
893 function RandomSkillLevel()
894 return "dumb"
895 end
896
897
898 -- vim: tw=80 ts=4
899
This page took 0.069408 seconds and 3 git commands to generate.