Advertisement
Al99

Game.h

Nov 11th, 2019
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.35 KB | None | 0 0
  1. #ifndef __Game__
  2. #define __Game__
  3.  
  4. #include<SDL2/SDL.h>
  5. #include<SDL2/SDL_image.h>
  6. #include <iostream>
  7. #include <string>
  8. #include <map>
  9. #include <vector>
  10. #include "Enemy.h"
  11. #include "Game.h"
  12. #include "GameObject.h"
  13. #include "InputHandler.h"
  14. #include "Player.h"
  15. #include "TextureManager.h"
  16. #include "Vector2d.h"
  17.  
  18. class Game
  19. {
  20.     public:
  21.     Game(){}
  22.     ~Game(){}
  23.    
  24.     // simply set the running variable to true
  25.     bool init(const char* title, int xpos, int ypos, int width,
  26.     int height, int flags);
  27.     void draw(SDL_Renderer*);
  28.     void render();
  29.     void update();
  30.     void handleEvents();
  31.     void clean();
  32.     void quit();
  33.    
  34.     // a function to access the private running variable
  35.     bool running() { return m_bRunning; }
  36.    
  37.     SDL_Renderer* getRenderer() const { return m_pRenderer; }
  38.    
  39.     static Game* Instance()
  40.     {
  41.         if (s_pInstance == 0)
  42.         {
  43.             s_pInstance = new Game();
  44.             return s_pInstance;
  45.         }
  46.         return s_pInstance;
  47.     }
  48.    
  49.     static Game *s_pInstance;
  50.    
  51.     private:
  52.        
  53.     SDL_Window* m_pWindow = 0;
  54.     SDL_Renderer* m_pRenderer = 0;
  55.     SDL_Surface* pTempSurface = 0;
  56.     SDL_Texture* m_pTexture = 0;
  57.     SDL_Rect m_sourceRectangle;
  58.     SDL_Rect m_destinationRectangle;
  59.    
  60.     bool m_bRunning;
  61.    
  62.     int m_currentFrame;
  63.  
  64.     GameObject *m_go;
  65.     GameObject *mplayer;
  66.  
  67.     std::vector<GameObject*> m_gameObjects;
  68.  
  69. };
  70.  
  71. typedef Game TheGame;
  72.  
  73. #endif /*defined(__Game__) */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement