// // Deus Hax (working title) // Copyright (c) 2010-2011 Sam Hocevar // #if defined HAVE_CONFIG_H # include "config.h" #endif #include #include #if defined _WIN32 # include #endif #include #include "core.h" #include "game.h" #include "sdlinput.h" #include "debugfps.h" #include "debugsprite.h" #include "debugsphere.h" #include "debugrecord.h" #include "debugstats.h" #if defined _WIN32 # undef main #endif static float const FPS = 30.0f; int main(int argc, char **argv) { /* Initialise SDL */ if (SDL_Init(SDL_INIT_VIDEO) < 0) { fprintf(stderr, "Cannot initialise SDL: %s\n", SDL_GetError()); return EXIT_FAILURE; } SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); SDL_Surface *video = SDL_SetVideoMode(640, 480, 0, SDL_OPENGL); if (!video) { fprintf(stderr, "Cannot create OpenGL screen: %s\n", SDL_GetError()); SDL_Quit(); return EXIT_FAILURE; } SDL_WM_SetCaption("Map Test (SDL)", NULL); SDL_ShowCursor(0); //SDL_WM_GrabInput(SDL_GRAB_ON); Ticker::Setup(FPS); /* Initialise OpenGL */ Video::Setup(video->w, video->h); /* Create a game */ #if defined _WIN32 _chdir(".."); /* Temporary Win32 hack */ #endif Game *game = new Game("maps/testmap.tmx"); game->SetMouse(160, 96); /* Register an input driver and some debug stuff */ new SdlInput(); new DebugFps(10, 10); new DebugSprite(game); new DebugSphere(); //new DebugRecord("lolengine.ogm", FPS); new DebugStats("stats.txt"); while (!Ticker::Finished()) { /* Tick the game */ Ticker::TickGame(); /* Tick the renderer, show the frame and clamp to desired framerate. */ Ticker::TickDraw(); SDL_GL_SwapBuffers(); Ticker::ClampFps(); } SDL_Quit(); return EXIT_SUCCESS; }