blobwarsAttrition/src/main.c

106 lines
1.8 KiB
C
Raw Normal View History

2018-01-21 10:31:38 +01:00
/*
Copyright (C) 2018 Parallel Realities
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "main.h"
static long capFrameRate(const long then);
2018-02-03 14:07:56 +01:00
static void handleCommandLine(int argc, char *argv[]);
2018-01-21 10:31:38 +01:00
2018-02-03 14:07:56 +01:00
int main(int argc, char *argv[])
2018-01-21 10:31:38 +01:00
{
2018-02-02 09:26:58 +01:00
long then, nextSecond, frames;
2018-01-21 10:31:38 +01:00
atexit(cleanup);
srand(time(NULL));
2018-02-03 14:07:56 +01:00
init18N(argc, argv);
2018-01-21 10:31:38 +01:00
initSDL();
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG);
initGameSystem();
handleCommandLine(argc, argv);
2018-02-02 09:26:58 +01:00
frames = 0;
2018-01-21 10:31:38 +01:00
nextSecond = SDL_GetTicks() + 1000;
while (1)
{
then = SDL_GetTicks();
handleInput();
app.delegate.logic();
prepareScene();
app.delegate.draw();
presentScene();
then = capFrameRate(then);
2018-02-02 09:26:58 +01:00
frames++;
2018-01-21 10:31:38 +01:00
if (SDL_GetTicks() >= nextSecond)
{
2018-02-02 09:26:58 +01:00
dev.fps = frames;
frames = 0;
2018-01-21 10:31:38 +01:00
game.timePlayed++;
nextSecond = SDL_GetTicks() + 1000;
}
}
return 0;
}
static long capFrameRate(const long then)
{
long wait;
wait = 16 - (SDL_GetTicks() - then);
if (wait > 0)
{
SDL_Delay(wait);
}
return SDL_GetTicks();
}
2018-02-03 14:07:56 +01:00
static void handleCommandLine(int argc, char *argv[])
2018-01-21 10:31:38 +01:00
{
int i;
for (i = 1 ; i < argc ; i++)
{
}
2018-01-28 13:01:39 +01:00
initAtlasTest();
2018-01-21 10:31:38 +01:00
}