Use vsync instead of delay-based synchronization
Also changed the game_update() interface to take dt in seconds as a double (rather than milliseconds as an unsigned integer) as we're now computing the refresh interval as a double anyway (by querying the display mode). To my eye (and on my machine), all chunkiness is now gone; the game feels very smooth.
This commit is contained in:
@@ -576,7 +576,7 @@ gamestatus_t game_evthandle(void *mem, const SDL_Event *evt)
|
||||
return GAMESTATUS_OK;
|
||||
}
|
||||
|
||||
gamestatus_t game_update(void *mem, unsigned dt)
|
||||
gamestatus_t game_update(void *mem, double dt)
|
||||
{
|
||||
gamestate_t *state = (gamestate_t *)mem;
|
||||
|
||||
@@ -590,7 +590,7 @@ gamestatus_t game_update(void *mem, unsigned dt)
|
||||
state->p.dir.x /= dmag;
|
||||
state->p.dir.y /= dmag;
|
||||
state->p.tex = state->pwalk;
|
||||
state->p.speed = WALKSPEED / 1000.0;
|
||||
state->p.speed = WALKSPEED;
|
||||
} else {
|
||||
state->p.tex = state->pidle;
|
||||
state->p.speed = 0;
|
||||
|
||||
Reference in New Issue
Block a user