I had a little fun with your code Added stars, flash and sound.
--# Main
displayMode(FULLSCREEN)
function setup()
backingMode(RETAINED)
delay(2,drawLightning)
flash = {0,0,0}
Galaxy.init(500)
end
function draw()
background(flash[1],flash[2], flash[3], 255)
noStroke()
fill(0, 0, 0, 13)
rect(0,0,WIDTH,HEIGHT)
Galaxy.draw()
end
function touched(t)
if t.state == ENDED then
drawLightning()
end
end
function drawLightning()
tween(1,flash,{255,255,255},tween.easing.bounceOutIn,function() flash = {0,0,0} end)
sound(SOUND_EXPLODE, 49833)
sound(DATA, "ZgNAAgBBXkcvcCR9H+lBP9a53T6wUVk+ZABZXV1aPztXXAdu")
local points = {}
local variation = vec2(60,100)
table.insert(points,vec2(math.random()*WIDTH,HEIGHT))
for i = 1,10 do
table.insert(
points,
vec2(
points[i].x+(math.random()-.5)*variation.x,
points[i].y-math.random()*variation.y
))
end
stroke(255, 255, 255, 255)
strokeWidth(15)
for i,v in ipairs(points) do
if points[i+1] then
line(v.x,v.y,points[i+1].x,points[i+1].y)
end
end
end
function delay(time,callback)
tween.delay(3,function() callback() delay(time,callback) end)
end
--# Galaxy
Galaxy = {}
Galaxy.count = 0
function Galaxy.init(count)
Galaxy.count = count
galaxy = {}
for i=1,count,1 do
galaxy[i] = Stars()
end
end
function Galaxy.draw()
for i=1,Galaxy.count,1 do
galaxy[i]:draw()
end
end
Stars = class()
function Stars:init(x,y)
-- you can accept and set parameters here
self.x = math.random(1,WIDTH)
self.y = math.random(1,HEIGHT)
self.m = mesh()
self.s1 = math.random(1,3)
self.s2 = math.random(1,3)
self.m.vertices = {vec3(0,0,0),
vec3(self.s1,0,0),
vec3(self.s1,self.s2,0)}
end
function Stars:draw()
-- Codea does not automatically call this method
--background(0,0,0,255)
pushMatrix()
translate(self.x,self.y)
self.m:setColors(255,255,255,math.random(1,255))
self.m:draw()
popMatrix()
end
function Stars:touched(touch)
-- Codea does not automatically call this method
end