seems to be a lot of vector maths (C add, mul) and table thrashing (C index)?
depends, but my understanding is that a sprite you tell it to draw at a float and it's different than the last float but still the same int, it will mark dirty. but if you told it to draw at an int last time and next time it's the same int, then it won't be marked dirty.
try this faster version
local floor <const> = math.floor
function Particle:update()
self.lifetime+=dt
self.position+=self.velocity*dt
self.position.x = floor(self.position.x+.5)
self.position.y = floor(self.position.y+.5)
end
and then this one
function Particle:update()
self.lifetime+=dt
self.position+=self.velocity*dt
self.position.x = (self.position.x+.5)//1
self.position.y = (self.position.y+.5)//1
end
not sure about this
function Particle:update()
self.lifetime+=dt
self.position+=self.velocity*dt
self:moveBy(0.5, 0.5)
end
or this
not sure about this
function Particle:update()
self.lifetime+=dt
self.position+=self.velocity*dt
self:moveTo((self.position.x+.5)//1, (self.position.y+.5)//1)
end
please report your benchmarks!
also see my benchmark thread Well… I didn’t expect that! (Benchmarks & Optimisations)