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

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