diff options
Diffstat (limited to 'src/complete.moon')
| -rw-r--r-- | src/complete.moon | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/complete.moon b/src/complete.moon new file mode 100644 index 0000000..f1af550 --- /dev/null +++ b/src/complete.moon @@ -0,0 +1,37 @@ +mod = ... + +mod.create_scene = () -> + ret = am.group! + ret\append(mod.starfield!) + ret ^ am.translate(0,0) ^ am.rotate(0) ^ am.sprite("data/complete.png") + ret + +stars = { + "data/star1.png" + "data/star2.png" + "data/star3.png" +} + +mod.starfield = () -> + ret = am.group! + ret\action(coroutine.create(() -> + while true + --Randomly create stars with a 0.01 chance + if math.random() < 0.2 + star_y = math.random(-256,256) + star_sprite = stars[math.random(#stars)] + star = am.translate(-512,star_y) ^ am.scale(1) ^ am.sprite(star_sprite) + starspeed = math.random(20,50) + star\action(coroutine.create(() -> + while star.x <= 550 + star.x += starspeed + coroutine.yield! + ret\remove(star) + coroutine.yield true + )) + ret\append(star) + coroutine.yield! + )) + ret + +mod |
