Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

80 строки
1.7 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 "debugsphere.h"
  16. #include "debugrecord.h"
  17. #include "debugstats.h"
  18. static float const FPS = 30.0f;
  19. int main(int argc, char **argv)
  20. {
  21. /* Initialise SDL */
  22. if (SDL_Init(SDL_INIT_VIDEO) < 0)
  23. {
  24. fprintf(stderr, "Cannot initialise SDL: %s\n", SDL_GetError());
  25. return EXIT_FAILURE;
  26. }
  27. SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
  28. SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
  29. SDL_Surface *video = SDL_SetVideoMode(640, 480, 0, SDL_OPENGL);
  30. if (!video)
  31. {
  32. fprintf(stderr, "Cannot create OpenGL screen: %s\n", SDL_GetError());
  33. SDL_Quit();
  34. return EXIT_FAILURE;
  35. }
  36. SDL_WM_SetCaption("Map Test (SDL)", NULL);
  37. SDL_ShowCursor(0);
  38. //SDL_WM_GrabInput(SDL_GRAB_ON);
  39. /* Initialise OpenGL */
  40. Video::Setup(video->w, video->h);
  41. /* Create a game */
  42. Game *game = new Game("maps/testmap.tmx");
  43. /* Register an input driver and some debug stuff */
  44. new SdlInput();
  45. new DebugFps();
  46. new DebugSprite(game);
  47. new DebugSphere();
  48. //new DebugRecord("lolengine.ogg");
  49. new DebugStats("stats.txt");
  50. while (!Ticker::Finished())
  51. {
  52. /* Tick the game */
  53. Ticker::TickGame();
  54. /* Clear the screen, tick the renderer, show the frame and
  55. * clamp to desired framerate. */
  56. Video::Clear();
  57. Ticker::TickDraw();
  58. SDL_GL_SwapBuffers();
  59. Ticker::ClampFps(1000.0f / FPS);
  60. }
  61. SDL_Quit();
  62. return EXIT_SUCCESS;
  63. }