2
0

Game.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // ----------------------------------------------------------------
  2. // From Game Programming in C++ by Sanjay Madhav
  3. // Copyright (C) 2017 Sanjay Madhav. All rights reserved.
  4. //
  5. // Released under the BSD License
  6. // See LICENSE in root directory for full details.
  7. // ----------------------------------------------------------------
  8. #pragma once
  9. #include <SDL/SDL.h>
  10. #include <unordered_map>
  11. #include <string>
  12. #include <vector>
  13. #include "Math.h"
  14. #include "SoundEvent.h"
  15. class Game
  16. {
  17. public:
  18. Game();
  19. bool Initialize();
  20. void RunLoop();
  21. void Shutdown();
  22. void AddActor(class Actor* actor);
  23. void RemoveActor(class Actor* actor);
  24. class Renderer* GetRenderer() { return mRenderer; }
  25. class AudioSystem* GetAudioSystem() { return mAudioSystem; }
  26. class PhysWorld* GetPhysWorld() { return mPhysWorld; }
  27. // Game-specific
  28. void AddPlane(class PlaneActor* plane);
  29. void RemovePlane(class PlaneActor* plane);
  30. std::vector<class PlaneActor*>& GetPlanes() { return mPlanes; }
  31. private:
  32. void ProcessInput();
  33. void HandleKeyPress(int key);
  34. void UpdateGame();
  35. void GenerateOutput();
  36. void LoadData();
  37. void UnloadData();
  38. // All the actors in the game
  39. std::vector<class Actor*> mActors;
  40. // Any pending actors
  41. std::vector<class Actor*> mPendingActors;
  42. class Renderer* mRenderer;
  43. class AudioSystem* mAudioSystem;
  44. class PhysWorld* mPhysWorld;
  45. Uint32 mTicksCount;
  46. bool mIsRunning;
  47. // Track if we're updating actors right now
  48. bool mUpdatingActors;
  49. // Game-specific code
  50. std::vector<class PlaneActor*> mPlanes;
  51. class FPSActor* mFPSActor;
  52. class SpriteComponent* mCrosshair;
  53. SoundEvent mMusicEvent;
  54. };