forked from eBrnd/caveblobb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
63 lines (53 loc) · 1.54 KB
/
main.cpp
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
#include <iostream>
#include <SDL.h>
#include <SDL_framerate.h>
#include "game.hpp"
#include <config/config.h>
#include "font.hpp"
int main(int argc, char** argv)
{
std::cout << "Caveblobb version " << VERSION_MAJOR << "."
<< VERSION_MINOR << "." << VERSION_PATCH << std::endl;
#ifdef HAS_MACOS
std::cout << "Running on MacOS." << std::endl;
#endif
// Start up SDL
if (SDL_Init(SDL_INIT_VIDEO) < 0)
{
std::cout << "Could not initialize SDL: " << SDL_GetError() << std::endl;
exit(1);
}
int sdlopts = SDL_SWSURFACE | SDL_DOUBLEBUF;
for(int i = 1; i < argc; i++)
{
std::string fullscreen ("--fullscreen");
std::string f ("-f");
if(!fullscreen.compare(argv[i]) || !f.compare(argv[i]))
sdlopts = SDL_SWSURFACE | SDL_FULLSCREEN;
//std::cout << "Fullscreen is broken. Sorry!" << std::endl;
std::string help ("--help");
std::string h ("-h");
if(!help.compare(argv[i]) || !h.compare(argv[i]))
{
std::cout << "~cavebl0bb~\n\nCommand line options:\n\t--fullscreen, -f\t\tStart in full screen mode." << std::endl;
exit(0);
}
}
SDL_Surface *display;
display = SDL_SetVideoMode(800, 600, 0, sdlopts); // HWSURFACE?
if(display == NULL)
{
std::cout << "Could not initialize video: " << SDL_GetError() << std::endl;
exit(1);
}
Game* game = new Game(display);
FPSmanager* fpsmanager = new FPSmanager();
SDL_initFramerate(fpsmanager);
SDL_setFramerate(fpsmanager, 60);
atexit(SDL_Quit);
while(true)
{
SDL_framerateDelay(fpsmanager);
game->frame();
}
}