Sorry if this is isn’t the proper category to post this in.
I am trying to apply deltaTime to the physics of the player object in my current platforming game project. I need to figure out how to properly apply deltaTime to the player’s walking and jumping velocity.
I am using simple math for the calculations. I am not using the Corona API physics.
The value of deltaTime in this case is from this tutorial.
I have researched numerous threads and articles on Corona Forum and elsewhere, but nothing I have tried so far has worked properly.
Simplified code without deltaTime:
[lua]
– master object class
Next Position X = Map Position X + Velocity X
Next Position Y = Map Position Y + Velocity Y
– player class
if( Analog Stick == Left )then
– increase walk speed left
Velocity X = Velocity X + Walk Speed * -1
– cap velocity at max speed left
if( Velocity X < Max Walk Speed *-1 )then
Velocity X = Max Walk Speed * -1
end
elseif( Analog Stick == Right )then
– increase walk speed right
Velocity X = Velocity X + Walk Speed
– cap velocity at max speed right
if( Velocity X > Max Walk Speed )then
Velocity X = Max Walk Speed
end
else
if( Velocity X > 0 )then
– decrease walk speed left
Velocity X = Velocity X + ( Friction * -1 )
if(Velocity X <= 0)then
Velocity X = 0
end
elseif( Velocity X < 0 )then
– decrease walk speed right
Velocity X = Velocity X + Friction
if( Velocity X > 0 )then
Velocity X = 0
end
end
end
if( Analog Stick == Up and Fall == 0 )then
– apply jump speed
Fall = 1
Velocity Y = Jump Speed * -1
end
– apply gravity
Velocity Y = Velocity Y + Gravity
end
[/lua]