Removed time delta, as it's leading to poor frame pacing.
This commit is contained in:
parent
2db4b4171d
commit
9ae3e4bfc0
34
src/main.c
34
src/main.c
|
@ -22,10 +22,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
static void handleMissionArgs(int argc, char *argv[]);
|
static void handleMissionArgs(int argc, char *argv[]);
|
||||||
static void handleLoggingArgs(int argc, char *argv[]);
|
static void handleLoggingArgs(int argc, char *argv[]);
|
||||||
|
static long capFrameRate(const long then);
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
float td;
|
|
||||||
long then, lastFrameTime, frames;
|
long then, lastFrameTime, frames;
|
||||||
long expireTextTimer;
|
long expireTextTimer;
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
|
@ -56,19 +56,15 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
handleMissionArgs(argc, argv);
|
handleMissionArgs(argc, argv);
|
||||||
|
|
||||||
dev.fps = frames = td = 0;
|
dev.fps = frames = 0;
|
||||||
then = SDL_GetTicks();
|
then = SDL_GetTicks();
|
||||||
lastFrameTime = SDL_GetTicks() + 1000;
|
lastFrameTime = SDL_GetTicks() + 1000;
|
||||||
expireTextTimer = SDL_GetTicks() + (1000 * 10);
|
expireTextTimer = SDL_GetTicks() + (1000 * 10);
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
td += (SDL_GetTicks() - then);
|
then = capFrameRate(then);
|
||||||
|
|
||||||
then = SDL_GetTicks();
|
|
||||||
|
|
||||||
while (td >= LOGIC_RATE)
|
|
||||||
{
|
|
||||||
while (SDL_PollEvent(&event))
|
while (SDL_PollEvent(&event))
|
||||||
{
|
{
|
||||||
switch (event.type)
|
switch (event.type)
|
||||||
|
@ -125,25 +121,15 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
app.delegate.logic();
|
app.delegate.logic();
|
||||||
|
|
||||||
td -= LOGIC_RATE;
|
|
||||||
|
|
||||||
if (app.doTrophyAlerts)
|
if (app.doTrophyAlerts)
|
||||||
{
|
{
|
||||||
doTrophyAlerts();
|
doTrophyAlerts();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (app.resetTimeDelta)
|
|
||||||
{
|
|
||||||
td = 0;
|
|
||||||
then = SDL_GetTicks();
|
|
||||||
app.resetTimeDelta = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
game.stats[STAT_TIME]++;
|
game.stats[STAT_TIME]++;
|
||||||
|
|
||||||
/* always zero the mouse motion */
|
/* always zero the mouse motion */
|
||||||
app.mouse.dx = app.mouse.dy = 0;
|
app.mouse.dx = app.mouse.dy = 0;
|
||||||
}
|
|
||||||
|
|
||||||
prepareScene();
|
prepareScene();
|
||||||
|
|
||||||
|
@ -204,6 +190,20 @@ int main(int argc, char *argv[])
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static long capFrameRate(const long then)
|
||||||
|
{
|
||||||
|
long wait;
|
||||||
|
|
||||||
|
wait = 16 - (SDL_GetTicks() - then);
|
||||||
|
|
||||||
|
if (wait > 0)
|
||||||
|
{
|
||||||
|
SDL_Delay(wait);
|
||||||
|
}
|
||||||
|
|
||||||
|
return SDL_GetTicks();
|
||||||
|
}
|
||||||
|
|
||||||
static void handleLoggingArgs(int argc, char *argv[])
|
static void handleLoggingArgs(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
|
@ -484,7 +484,6 @@ typedef struct {
|
||||||
} Mouse;
|
} Mouse;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int resetTimeDelta;
|
|
||||||
char saveDir[MAX_FILENAME_LENGTH];
|
char saveDir[MAX_FILENAME_LENGTH];
|
||||||
int saveGame;
|
int saveGame;
|
||||||
int winWidth;
|
int winWidth;
|
||||||
|
|
|
@ -43,6 +43,4 @@ void endSectionTransition(void)
|
||||||
{
|
{
|
||||||
SDL_Delay(elasped);
|
SDL_Delay(elasped);
|
||||||
}
|
}
|
||||||
|
|
||||||
app.resetTimeDelta = 1;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue