Hello Hio,
Vrav is right. I have very little experience with programming but i learned very recently about this very topic. different speeds are caused by different processors and also how much processing the computer is doing. Little known fact: in the original “space invaders”, the game gets faster with every alien you shoot, because the frame rate increases when the processor has to render fewer objects. However, in your case (and in many cases), this is not a desired behaviour. That’s why we have dt.
dt is a variable that is the time between frames. Other calculations are only based on frame rate, and will therefore vary device to device (and also processor to processor, and also depending on how fast the game is rendering).
Here’s an example of code with dt. This code moves a star from the bottom of the screen to the top, then changes itself to a random x position, and starts again.
local speed = 250
function update(self, dt)
p = go.get_position()
p.y = p.y + speed * dt
if p.y > 800 then
p.y = -200
p.x = math.random(10,250) *3
print(p)
end
go.set_position(p)
end