main.cxx 710 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #include "SDL.hxx"
  2. #include "SDLWindow.hxx"
  3. #include <cstdlib>
  4. void main_loop(SDLWindow& window)
  5. {
  6. for (;;) {
  7. SDL_Event evt;
  8. while (SDL_PollEvent(&evt)!=0) {
  9. if (evt.type==SDL_QUIT) {
  10. return;
  11. }
  12. }
  13. // Game logic, render... (Implement your logic here if needed.)
  14. SDL_Delay(16);
  15. }
  16. }
  17. int main(int argc, char** argv) try
  18. {
  19. SDL sdl{};
  20. SDLWindow window{
  21. "Snake",
  22. SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
  23. 0, 0,
  24. SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_BORDERLESS
  25. };
  26. main_loop(window);
  27. return EXIT_SUCCESS;
  28. } catch (std::exception const& ex) {
  29. SDL_LogError(SDL_LOG_CATEGORY_ERROR, "%s", ex.what());
  30. return EXIT_FAILURE;
  31. }