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