Game.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 <ECS.h>
  15. #include <AssetStore.h>
  16. #include <EventBus.h>
  17. const uint8_t FPS = 60;
  18. const uint32_t MILLISECS_PER_FRAME = 1000 / FPS;
  19. class Game
  20. {
  21. private:
  22. bool isRunning;
  23. bool isDebug;
  24. uint32_t millisecsPerviousFrame;
  25. SDL_Window *window;
  26. SDL_Renderer *renderer;
  27. SDL_Rect camera;
  28. std::unique_ptr<Registry> registry;
  29. std::unique_ptr<AssetStore> assetStore;
  30. std::unique_ptr<EventBus> eventBus;
  31. public:
  32. Game();
  33. ~Game();
  34. void Initialize();
  35. void Run();
  36. void Destroy();
  37. void Setup();
  38. void ProcessInput();
  39. void Render();
  40. void Update();
  41. void LoadLevel(int level);
  42. static uint32_t windowsWidth;
  43. static uint32_t windowsHeight;
  44. static uint32_t mapWidth;
  45. static uint32_t mapHeight;
  46. };
  47. #endif /* GAMEENGINE_GAME_H */