Hi. I'm trying to develop a simple racing 2d game (view top-down) in C#, sdl.net.
Now, I'm trying to manage speed, acceleration and brakes of my car.
My problem is the algorithm.
I have the loop (Events_Tick)
executed 50 times per seconds, where the position of my car is processed like the following:
private void Events_Tick(object sender, TickEventArgs e)
{
car.ProcessPosition();
}
and ProcessPosition
is something like:
if (throttle)
{
speed += 1;
x += 1;
}
and finally, I draw my sprite on the new X.
The problem is that it is too fast!
So I'm asking you how to maintain 50 FPS (frames per second) and move my sprite (the car) only N pixels per second (based on its speed).
Thank you in advance! Regards!