Hello again,
I am almost close to finishing my first ever game, thanks to all your help till now.
While my game runs fine with a fixed speed (for parallax effect), I am unable to find a good balance to increase speed of my game as time progresses.
Here is my current setup, with delta time considerations. Currently, I increase speed every 5 secs, but that seems non-linear/jerky, my game feels there is sudden increase of speed instead of a smooth gradual one.
local speed = 100
local function increaseSpeed()
speed = speed*1.1
end
local function update()
-- delta time calc
local curT = system.getTimer()
local dT = (curT - lastT)/1000
lastT = curT
local dX = math.round(dT * speed)
for i = 1, #backgrounds do
local b = backgrounds[i]
b:translate(-(dX * .5), 0)
end
end
timer.performWithDelay(5000, increaseSpeed, 0)
Runtime:addEventListener("enterFrame", update)
How can I make my speed a function of timeElapsed, while taking into account the deltaTime considerations as well to have a smooth/gradual game speed increase ?