GEJM  1.0.0.0
a 2D platformer made by students
ViewModel.h
1 #ifndef VIEWMODEL_H
2 #define VIEWMODEL_H
3 
4 #include "Game.h"
5 #include "SDLWrapper.h"
6 #include "Timer.h"
7 
11 enum class TextAlignment
12 {
13  Left,
14  Right,
15  Center
16 };
17 
22 class ViewModel
23 {
24 public:
30  ViewModel(Game* const game, SDLWrapper* const sdlWrapper);
31 
35  ~ViewModel();
36 
41  void handleEvents();
42 
48  void drawLoop();
49 
53  ViewModel& operator=(ViewModel const&) = delete;
54 
55 private:
59  Game* const game;
60 
64  SDLWrapper* const sdlWrapper;
65 
69  bool hasDrawnPauseMenu;
70 
74  SDL_Rect camera;
75 
79  Timer fpsTimer;
80 
84  Timer curFPSTimer;
85 
89  int countedFrames;
90 
94  int otherCountedFrames;
95 
99  float avgFPS;
100 
104  int curFPS;
105 
109  Timer fadeTimer;
110 
115  void drawGame();
116 
121  void drawMenu();
122 
127  void drawPauseMenu();
128 
133  void drawLost();
134 
139  void drawWon();
140 
151  void drawButton(int buttonX, int buttonY, int buttonWidth, int buttonHeight, SDL_Texture* texture, void(Game::*onClick)());
152 
161  void drawText(int x, int y, SDL_Texture* texture, TextAlignment align = TextAlignment::Center);
162 
167  void correctFPS();
168 
173  void currentFPS();
174 };
175 
176 #endif // VIEWMODEL_H
Definition: Timer.h:9
Definition: SDLWrapper.h:63
Definition: ViewModel.h:22
Definition: Game.h:53