Game.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * 2D Game Engine
  3. * Game.h: Base Game engine class header
  4. * Based on pikuma.com 2D game engine in C++ and Lua course
  5. * Copyright (c) 2021 986-Studio. All Right Reserved
  6. *
  7. * Created by Manoël Trapier on 09/02/2021.
  8. */
  9. #ifndef GAMEENGINE_GAME_H
  10. #define GAMEENGINE_GAME_H
  11. #include <stdint.h>
  12. #include <memory>
  13. #include <SDL.h>
  14. #include <sol/sol.hpp>
  15. #include <ECS.h>
  16. #include <AssetStore.h>
  17. #include <EventBus.h>
  18. const uint8_t FPS = 60;
  19. const uint32_t MILLISECS_PER_FRAME = 1000 / FPS;
  20. class Game
  21. {
  22. private:
  23. bool isRunning;
  24. bool isDebug;
  25. uint32_t millisecsPerviousFrame;
  26. SDL_Window *window;
  27. SDL_Renderer *renderer;
  28. SDL_Rect camera;
  29. std::unique_ptr<Registry> registry;
  30. std::unique_ptr<AssetStore> assetStore;
  31. std::unique_ptr<EventBus> eventBus;
  32. sol::state lua;
  33. public:
  34. Game();
  35. ~Game();
  36. void Initialize();
  37. void Run();
  38. void Destroy();
  39. void Setup();
  40. void ProcessInput();
  41. void Render();
  42. void Update();
  43. static uint32_t windowsWidth;
  44. static uint32_t windowsHeight;
  45. static uint32_t mapWidth;
  46. static uint32_t mapHeight;
  47. };
  48. #endif /* GAMEENGINE_GAME_H */