Yeap.
I do not know the cost of a local variable ! I will make some tests !
It is difficult to optimize at this stage
Original code was
local a2 = a * a
local oStar = tStar[s]
if oStar ~= nil then
local dx, dy = oStar.dx, oStar.dy
local o = oStar.o
o.x = sx + dx * a
o.y = sy + dy * a + a2
o.rotation = dx * a
o.alpha = (100 - a) * 0.01
end
end
Finally I tried to precalculate the motion of the stars
The code is now this one, but I do not know if it is really faster
local a40 = a * 4
local a41 = a40 + 1
local a42 = a40 + 2
local a43 = a40 + 3
local oStar = tStar[s]
if oStar ~= nil then
local tMove = oStar.tMove
local o = oStar.o
o.x = sx + tMove[a40]
o.y = sy + tMove[a41]
o.rotation = tMove[a42]
o.alpha = tMove[a43]
end
end
I could replace table of values by a table of objects
the code would be like this
local oStar = tStar[s]
if oStar ~= nil then
local oMove = oStar.tMove[a]
local o = oStar.o
o.x = sx + oMove.x
o.y = sy + oMove.y
o.rotation = oMove.r
o.alpha = oMove.a
end
end
I will have to make big loops to see if there is really a code that stands out!
Finally, I saw Lava_Flow particles demo in the sample folder.
It could be the better way to do what I want to !