2
0

Game.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. // Vector2 struct just stores x/y coordinates
  11. // (for now)
  12. struct Vector2
  13. {
  14. float x;
  15. float y;
  16. };
  17. // Game class
  18. class Game
  19. {
  20. public:
  21. Game();
  22. // Initialize the game
  23. bool Initialize();
  24. // Runs the game loop until the game is over
  25. void RunLoop();
  26. // Shutdown the game
  27. void Shutdown();
  28. private:
  29. // Helper functions for the game loop
  30. void ProcessInput();
  31. void UpdateGame();
  32. void GenerateOutput();
  33. // Window created by SDL
  34. SDL_Window* mWindow;
  35. // Renderer for 2D drawing
  36. SDL_Renderer* mRenderer;
  37. // Number of ticks since start of game
  38. Uint32 mTicksCount;
  39. // Game should continue to run
  40. bool mIsRunning;
  41. // Pong specific
  42. // Direction of paddle
  43. int mPaddleDir;
  44. // Position of paddle
  45. Vector2 mPaddlePos;
  46. // Position of ball
  47. Vector2 mBallPos;
  48. // Velocity of ball
  49. Vector2 mBallVel;
  50. };