aboutsummaryrefslogtreecommitdiff
path: root/src/complete.moon
blob: f1af550b6a53174c9994ae3f32cededbb123e9c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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