So I'm slowly going insane over this, hopefully my error will be obvious to someone.
I have my game running on windows and the GP2X, the only problem is movement in the GP2X version is slower than the windows version, even though I thought I had made it frame rate independent. ie: you can walk from the bottom left to the bottom right of the game world faster on windows than the GP2X.
I have a tick interval in place in my game loop that I thought was restricting my update function (which moves the player) to only be called every X milliseconds. Heres some simplified code taken from my work:
CODE
const int TICK_INTERVAL = 35;
int lastUpdateTime = 0;
int elapsedTime = 0;
while the game is running
{
elapsedTime = SDL_GetTicks() - lastUpdateTime;
// only perform world updates at given tick intervals.
if( elapsedTime >= TICK_INTERVAL )
{
// record the time we updated at.
lastUpdateTime = SDL_GetTicks();
keyStates = InputHandler->RetrieveInput( );
// moves the player around the virtual world based on input.
world->update( keyStates );
world->checkCollisions( );
}
ClearScreen();
world->Render(); // render the world as fast as possible.
}
I know for a fact there must be a bug somewhere in there because I monitored the number of times world->update() was called for each platform (this is what causes movement of the player) and on the windows platform it is called more often than on the GP2X, hence the reason why you end up moving faster on the windows version.
The only way I see the windows version being able to perform more updates than the GP2X is if the GP2X can't manage to do the a full loop in TICK_INTERVAL, but even if I up this value to something stupid around, 200 for example, I still experience a speed difference between the two platforms.
Any help is greatly appreciated, thanks.
I have my game running on windows and the GP2X, the only problem is movement in the GP2X version is slower than the windows version, even though I thought I had made it frame rate independent. ie: you can walk from the bottom left to the bottom right of the game world faster on windows than the GP2X.
I have a tick interval in place in my game loop that I thought was restricting my update function (which moves the player) to only be called every X milliseconds. Heres some simplified code taken from my work:
CODE
const int TICK_INTERVAL = 35;
int lastUpdateTime = 0;
int elapsedTime = 0;
while the game is running
{
elapsedTime = SDL_GetTicks() - lastUpdateTime;
// only perform world updates at given tick intervals.
if( elapsedTime >= TICK_INTERVAL )
{
// record the time we updated at.
lastUpdateTime = SDL_GetTicks();
keyStates = InputHandler->RetrieveInput( );
// moves the player around the virtual world based on input.
world->update( keyStates );
world->checkCollisions( );
}
ClearScreen();
world->Render(); // render the world as fast as possible.
}
I know for a fact there must be a bug somewhere in there because I monitored the number of times world->update() was called for each platform (this is what causes movement of the player) and on the windows platform it is called more often than on the GP2X, hence the reason why you end up moving faster on the windows version.
The only way I see the windows version being able to perform more updates than the GP2X is if the GP2X can't manage to do the a full loop in TICK_INTERVAL, but even if I up this value to something stupid around, 200 for example, I still experience a speed difference between the two platforms.
Any help is greatly appreciated, thanks.