Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

74 righe
1.5 KiB

  1. //
  2. // Deus Hax (working title)
  3. // Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
  4. //
  5. #if defined HAVE_CONFIG_H
  6. # include "config.h"
  7. #endif
  8. #include <cstdio>
  9. #include <cmath>
  10. #include <SDL.h>
  11. #include "core.h"
  12. #include "sdlinput.h"
  13. #include "debugfps.h"
  14. #include "debugsprite.h"
  15. #include "debugrecord.h"
  16. static float const FPS = 30.0f;
  17. int main(int argc, char **argv)
  18. {
  19. /* Initialise SDL */
  20. if (SDL_Init(SDL_INIT_VIDEO) < 0)
  21. {
  22. fprintf(stderr, "Cannot initialise SDL: %s\n", SDL_GetError());
  23. return EXIT_FAILURE;
  24. }
  25. SDL_Surface *video = SDL_SetVideoMode(640, 480, 0, SDL_OPENGL);
  26. if (!video)
  27. {
  28. fprintf(stderr, "Cannot create OpenGL screen: %s\n", SDL_GetError());
  29. SDL_Quit();
  30. return EXIT_FAILURE;
  31. }
  32. SDL_WM_SetCaption("Map Test (SDL)", NULL);
  33. SDL_ShowCursor(0);
  34. //SDL_WM_GrabInput(SDL_GRAB_ON);
  35. /* Initialise OpenGL */
  36. Video::Setup(video->w, video->h);
  37. /* Create a game */
  38. Game *game = new Game("maps/testmap.tmx");
  39. /* Register an input driver and some debug stuff */
  40. new SdlInput();
  41. new DebugFps();
  42. new DebugSprite(game);
  43. //new DebugRecord("lolengine.ogg");
  44. while (!Ticker::Finished())
  45. {
  46. /* Tick the game */
  47. Ticker::TickGame();
  48. /* Clear the screen, tick the renderer, show the frame and
  49. * clamp to desired framerate. */
  50. Video::Clear();
  51. Ticker::TickDraw();
  52. SDL_GL_SwapBuffers();
  53. Ticker::ClampFps(1000.0f / FPS);
  54. }
  55. SDL_Quit();
  56. return EXIT_SUCCESS;
  57. }