starscanmove

This commit is contained in:
PossiblyAxolotl 2022-07-18 17:12:56 -06:00
parent c4d911c673
commit 90a8044ec4

View file

@ -6,7 +6,7 @@ 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)}
@ -14,8 +14,21 @@ function createStars()
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