|
@@ -1,156 +0,0 @@
|
|
|
--- title: simple particle system
|
|
|
--- author: pixelbath
|
|
|
--- desc: basic particle system, first used in Alter Ego by Kyuchumimo
|
|
|
--- script: lua
|
|
|
-
|
|
|
-t=0
|
|
|
-x=96
|
|
|
-y=24
|
|
|
-
|
|
|
-particles = {}
|
|
|
-local starcolors = { 8, 9, 10, 11, 12 }
|
|
|
-local snowcolors = { 12, 13 }
|
|
|
-local raincolors = { 8, 9 } -- in order of depth, farthest to closest
|
|
|
--- rain|snow|stars
|
|
|
-particletype = 'snow'
|
|
|
-
|
|
|
--- numparticles = number of particles to show
|
|
|
-function particleinit(numparticles)
|
|
|
- -- initialize
|
|
|
- particles = {}
|
|
|
- for i = 0, numparticles do
|
|
|
- table.insert(particles, {
|
|
|
- x = math.random() * 240,
|
|
|
- y = math.random() * 136,
|
|
|
- lastx = 0,
|
|
|
- lasty = 0,
|
|
|
- color = 2,
|
|
|
- t = 0,
|
|
|
- vel = 0,
|
|
|
- })
|
|
|
- end
|
|
|
- if particletype == 'stars' then
|
|
|
- for i = 1, #particles do
|
|
|
- particles[i].twinkle = math.random() > 0.49 -- randomly pick true/false
|
|
|
- particles[i].color = starcolors[math.random(#starcolors)]
|
|
|
- end
|
|
|
- end
|
|
|
- if particletype == 'rain' then
|
|
|
- for i = 1, #particles do
|
|
|
- particles[i].vel = math.random(4) + 1
|
|
|
- particles[i].color = raincolors[1]
|
|
|
- if particles[i].vel > 3.1 then
|
|
|
- particles[i].color = raincolors[2]
|
|
|
- end
|
|
|
- end
|
|
|
- end
|
|
|
- if particletype == 'snow' then
|
|
|
- for i = 1, #particles do
|
|
|
- particles[i].color = snowcolors[1]
|
|
|
- particles[i].vel = math.random() + 0.2
|
|
|
- if particles[i].vel > 0.8 then
|
|
|
- particles[i].color = snowcolors[2]
|
|
|
- end
|
|
|
- end
|
|
|
- end
|
|
|
-end
|
|
|
-
|
|
|
-function particleupdate()
|
|
|
- if particletype == 'stars' then
|
|
|
- for i = 1,#particles do
|
|
|
- local p = particles[i]
|
|
|
- if not p.twinkle then goto continueTwinkle end
|
|
|
- if t % 15 == 0 and math.random() > 0.1 then
|
|
|
- p.color = starcolors[math.random(#starcolors)]
|
|
|
- end
|
|
|
- ::continueTwinkle::
|
|
|
- end
|
|
|
- end
|
|
|
- if particletype == 'rain' then
|
|
|
- for i = 1,#particles do
|
|
|
- local p = particles[i]
|
|
|
- if p.lasty and p.lasty > 136 then
|
|
|
- p.y = 0
|
|
|
- p.lasty = 0
|
|
|
- p.x = math.random() * 260 - 10
|
|
|
- end
|
|
|
- p.lasty = p.y
|
|
|
- p.lastx = p.x
|
|
|
- p.x = p.x - p.vel / 5
|
|
|
- p.y = p.y + p.vel * 1.5
|
|
|
- end
|
|
|
- end
|
|
|
- if particletype == 'snow' then
|
|
|
- for i = 1,#particles do
|
|
|
- local p = particles[i]
|
|
|
- if p.y and p.y > 136 then
|
|
|
- p.y = 0
|
|
|
- p.lasty = 0
|
|
|
- p.x = math.random() * 260 - 10
|
|
|
- end
|
|
|
- p.x = p.x - (math.random() - 0.4)
|
|
|
- p.y = p.y + p.vel
|
|
|
- end
|
|
|
- end
|
|
|
-end
|
|
|
-
|
|
|
-function particledraw()
|
|
|
- if (particletype == 'rain') then
|
|
|
- for i = 1,#particles do
|
|
|
- local p = particles[i]
|
|
|
- line(p.x, p.y, p.lastx, p.lasty, p.color)
|
|
|
- end
|
|
|
- return
|
|
|
- end
|
|
|
- for i = 1,#particles do
|
|
|
- local p = particles[i]
|
|
|
- pix(p.x, p.y, p.color)
|
|
|
- end
|
|
|
-end
|
|
|
-
|
|
|
--- init here for title screen
|
|
|
-particleinit(150)
|
|
|
-
|
|
|
-
|
|
|
-function TIC()
|
|
|
-
|
|
|
- if btn(0) then y=y-1 end
|
|
|
- if btn(1) then y=y+1 end
|
|
|
- if btn(2) then x=x-1 end
|
|
|
- if btn(3) then x=x+1 end
|
|
|
-
|
|
|
- cls(0)
|
|
|
- particleupdate()
|
|
|
- particledraw()
|
|
|
-
|
|
|
- spr(1+t%60//30*2,x,y,14,3,0,0,2,2)
|
|
|
- print("HELLO WORLD!",84,84)
|
|
|
-
|
|
|
- t=t+1
|
|
|
-end
|
|
|
-
|
|
|
--- <TILES>
|
|
|
--- 001:eccccccccc888888caaaaaaaca888888cacccccccacc0ccccacc0ccccacc0ccc
|
|
|
--- 002:ccccceee8888cceeaaaa0cee888a0ceeccca0ccc0cca0c0c0cca0c0c0cca0c0c
|
|
|
--- 003:eccccccccc888888caaaaaaaca888888cacccccccacccccccacc0ccccacc0ccc
|
|
|
--- 004:ccccceee8888cceeaaaa0cee888a0ceeccca0cccccca0c0c0cca0c0c0cca0c0c
|
|
|
--- 017:cacccccccaaaaaaacaaacaaacaaaaccccaaaaaaac8888888cc000cccecccccec
|
|
|
--- 018:ccca00ccaaaa0ccecaaa0ceeaaaa0ceeaaaa0cee8888ccee000cceeecccceeee
|
|
|
--- 019:cacccccccaaaaaaacaaacaaacaaaaccccaaaaaaac8888888cc000cccecccccec
|
|
|
--- 020:ccca00ccaaaa0ccecaaa0ceeaaaa0ceeaaaa0cee8888ccee000cceeecccceeee
|
|
|
--- </TILES>
|
|
|
-
|
|
|
--- <WAVES>
|
|
|
--- 000:00000000ffffffff00000000ffffffff
|
|
|
--- 001:0123456789abcdeffedcba9876543210
|
|
|
--- 002:0123456789abcdef0123456789abcdef
|
|
|
--- </WAVES>
|
|
|
-
|
|
|
--- <SFX>
|
|
|
--- 000:000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000304000000000
|
|
|
--- </SFX>
|
|
|
-
|
|
|
--- <PALETTE>
|
|
|
--- 000:1a1c2c5d275db13e53ef7d57ffcd75a7f07038b76425717929366f3b5dc941a6f673eff7f4f4f494b0c2566c86333c57
|
|
|
--- </PALETTE>
|
|
|
-
|