diff --git a/Source/Particles.lua b/Source/Particles.lua index b1eb051..a379f2d 100644 --- a/Source/Particles.lua +++ b/Source/Particles.lua @@ -6,16 +6,29 @@ local exps = {} local stars = {} -function createStars() +function createStars(targetVelocityX,targetVelocityY) stars = {} for _i = 1, 30, 1 do stars[#stars+1] = {x=math.random(0,400),y=math.random(0,240),dx=math.random(-1.0,1.0)*0.5,dy=math.random(-1.0,1.0)*0.5,size=math.random(2,4)} end - + for star = 1, #stars do star = stars[star] - if star.dx == 0 then star.dx = 0.2 end - if star.dy == 0 then star.dy = 0.2 end + + if targetVelocityX then + star.dx += targetVelocityX + else + targetVelocityX = 0 + end + + if targetVelocityY then + star.dy += targetVelocityY + else + targetVelocityY = 0 + end + + if star.dx == 0 then star.dx = 0.2 + targetVelocityX end + if star.dy == 0 then star.dy = 0.2 + targetVelocityY end end end