I understand why it does that but I don't really have any idea of how to prevent that. So the scenario is, every frame I move the car by a certain of predefined pixels. What happens is when I go on slow or faster computer... well I get less or more frames per seconds so the car moves either slower or faster. I was wondering how I could prevent that.
I suspect that I would have the same problem using any library... This is my first time doing real time stuff like that.
So, if you feel that your car isn't going fast in your racing game, then maybe all you need to do is tweak some settings, get a bigger monitor, and use your gaming headset. With that, you get a better driving experience, all in the safety of your room.
"TypeRush is a really fun typing game for kids where players are given a series of sentences to copy. The more quickly and accurately you type, the faster you propel your car or boat through the race.
I suspect your current code looks somehow like this
// to be called every frame
void OnEveryFrame()
{
MoveCar();
DrawCarToScreen();
}
But it should be like this:
// to be called - for example - 50 times per second:
void OnEveryTimerEvent()
{
MoveCar();
}
// to be called every frame
void OnEveryFrame()
{
LockTimerEvents();
DrawCarToScreen();
UnlockAndProcessOutstandingTimerEvents();
}
You have to set up an according timer event, of course.
Move car according to timers and not framerate. i.e. Car model should be independent of the display representation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With