Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function _init()
- cls()
- print("stars")
- t = 0
- stars = {}
- for i=1,25 do
- add(stars,agent.new(i))
- end
- for s in all(stars) do
- s:reset()
- end
- end
- function _draw()
- cls()
- for s in all(stars) do
- s:update()
- s:draw()
- end
- end
- colors = {1,2,6,7}
- agent = {}
- agent.new = function(i)
- s={}
- s.i=i
- s.delay = rnd(60)
- s.t=0
- s.c=colors[i%4+1] -- 1,2,6,7
- s.r=1
- s.reset = function(s)
- s.a=rnd(6.18)
- s.x=64+sin(s.a)*rnd(16)
- s.y=64+cos(s.a)*rnd(8)
- s.z=0
- s.u=0
- s.v=0
- s.w=rnd(1)/4
- end
- s.update = function(s)
- s.t+=1
- if s.t < s.delay then return end
- s.u=abs(s.x-64)
- s.v=abs(s.y-64)
- i=t/30 * 3.14
- s.x+=sin(s.a)
- s.y+=cos(s.a)
- s.r=sin(s.t)*4+2
- s.z+=s.w
- if s.z > 4 then
- s.x+=sin(s.a)
- s.y+=cos(s.a)
- end
- if s.x<0 or s.x>128 then s:reset() end
- if s.y<0 or s.y>128 then s:reset() end
- end
- s.draw = function(s)
- if s.t < s.delay then return end
- -- r = s.v/64 * 3
- -- r += s.u/64
- r = s.z * 0.3
- circfill(s.x,s.y,r,s.c)
- end
- return s
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement