Creation of physics project
[physics.git] / src / game.cpp
CommitLineData
ad9f1fb6
PG
1#include "game.h"
2
3#include "GameStates/GameState.h"
4#include "GameStates/Running.h"
5#include "GameStates/Paused.h"
6#include "GameStates/CreatingPolygon.h"
7
8#include <vector>
9using std::vector;
10
11
12/// ***** Private Variables *****
13
14// The stack of active game states
15vector<GameState*> active_States;
16
17// Pointers to each possible game state
18// inserted and removed from the active_States
19Running* running;
20Paused* paused;
21CreatingPolygon* creating_Polygon;
22
23
24/// ***** Public Methods *****
25void gameInit()
26{
27 running = new Running();
28 paused = new Paused();
29 creating_Polygon = new CreatingPolygon();
30}
31
32void gameClean()
33{
34 delete creating_Polygon;
35 delete paused;
36 delete running;
37}
38
39void gameInput()
40{
41 int size = active_States.size();
42 for( int i = 0;
43 i < size;
44 i++ )
45 {
46 if( i-1 == size )
47 active_States[i]->handleInput(true);
48 else
49 active_States[i]->handleInput(false);
50 }
51
52}
53
54void gameUpdate(float time_step)
55{
56 int size = active_States.size();
57 for( int i = 0;
58 i < size;
59 i++ )
60 {
61 if( i-1 == size )
62 active_States[i]->update(time_step, true);
63 else
64 active_States[i]->update(time_step, false);
65 }
66}
67
68void gameDraw()
69{
70 int size = active_States.size();
71 for( int i = 0;
72 i < size;
73 i++ )
74 {
75 if( i-1 == size )
76 active_States[i]->draw(true);
77 else
78 active_States[i]->draw(false);
79 }
80}