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