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