Game Engine 2D Platformer
Timer.h
Go to the documentation of this file.
1 
7 //Using SDL, SDL_image, SDL_ttf, standard IO, strings, and string streams
8 #include <SDL2/SDL.h>
9 #include <stdio.h>
10 const int SCREEN_FPS = 60;
11 const int SCREEN_TICK_PER_FRAME = 1000 / SCREEN_FPS;
12 
13 //The application time based timer
14 class Timer
15 {
16 public:
17  //Initializes variables
18  Timer();
19 
20  //The various clock actions
21  void start();
22  void stop();
23  void pause();
24  void unpause();
25 
26  //Gets the timer's time
27  Uint32 getTicks();
28 
29  //Checks the status of the timer
30  bool isStarted();
31  bool isPaused();
32 
33 private:
34  //The clock time when the timer started
35  Uint32 mStartTicks;
36 
37  //The ticks stored when the timer was paused
38  Uint32 mPausedTicks;
39 
40  //The timer status
41  bool mPaused;
42  bool mStarted;
43 };
const int SCREEN_FPS
Definition: Timer.h:10
const int SCREEN_TICK_PER_FRAME
Definition: Timer.h:11
Definition: Timer.h:15
void pause()
Definition: Timer.cpp:38
bool isStarted()
Definition: Timer.cpp:92
void start()
Definition: Timer.cpp:12
Uint32 getTicks()
Definition: Timer.cpp:68
Timer()
Definition: Timer.cpp:2
void stop()
Definition: Timer.cpp:25
void unpause()
Definition: Timer.cpp:52
bool isPaused()
Definition: Timer.cpp:98