starscanmove
This commit is contained in:
parent
c4d911c673
commit
90a8044ec4
1 changed files with 17 additions and 4 deletions
|
@ -6,7 +6,7 @@ local exps = {}
|
||||||
|
|
||||||
local stars = {}
|
local stars = {}
|
||||||
|
|
||||||
function createStars()
|
function createStars(targetVelocityX,targetVelocityY)
|
||||||
stars = {}
|
stars = {}
|
||||||
for _i = 1, 30, 1 do
|
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)}
|
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
|
for star = 1, #stars do
|
||||||
star = stars[star]
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue