Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
blob: 76f7277646c981f373c7bbb84b57f48b14f7e18c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/* client/main.cc
   This file is part of the Osirion project and is distributed under 
   the terms and conditions of the GNU General Public License version 2 
*/

// SDL headers
#include <SDL/SDL.h>

// C++ headers
#include <iostream>

// project headers
#include "osirion.h"
#include "game/game.h"

#include "input.h"
#include "video.h"

void quit(int status)
{
	SDL_Quit();
	exit(status);
}

int main( int argc, char *argv[] )
{
	std::cout << "Project::OSiRiON " << OSIRION_VERSION << std::endl;

	// Initialize the video subsystem
	client::Video::init();
	if (!client::Video::initialized) {
		quit(1);
	}

	// initialize input
	client::Input::init();

    	// initialize game
	game::init();

	Uint32 startup = SDL_GetTicks();
	while(game::initialized) {
		Uint32 chrono = SDL_GetTicks();
	
		// overflow protection ~49 days
		if (chrono < startup) {
			startup = chrono;
		}
		
		// update the game chronometers
		float elapsed = (float) ( chrono - startup) / 1000.0f;
		game::update(elapsed);

		// update the video chronometers and draw
		client::Video::draw(elapsed);
		startup = chrono;

		// process input
		client::Input::process();
	}

	client::Video::shutdown();

	quit(0);
}