gravity working through manager
[physics.git] / src / game.cpp
... / ...
CommitLineData
1#include "game.h"
2#include "debug.h"
3
4#include <vector>
5using std::vector;
6
7#include "entityCreator.h"
8#include "effectManager.h"
9
10#include "GameStates/GameState.h"
11#include "GameStates/Running.h"
12#include "GameStates/Paused.h"
13#include "GameStates/CreatingPolygon.h"
14
15/// ***** Private Variables *****
16
17// The stack of active game states
18vector<GameState*> active_States;
19
20// Pointers to each possible game state
21// inserted and removed from the active_States
22Running* running;
23Paused* paused;
24CreatingPolygon* creating_Polygon;
25
26
27/// ***** Public Methods *****
28void gameInit()
29{
30 running = new Running();
31 paused = new Paused();
32 creating_Polygon = new CreatingPolygon();
33
34 // create starting entities
35 creator::init();
36
37 active_States.push_back(running);
38
39 effect::init();
40
41#ifdef DEBUGGING
42 cout << "World Created" << endl;
43#endif
44}
45
46void gameClean()
47{
48 effect::clean();
49
50 creator::clean();
51
52 delete creating_Polygon;
53 delete paused;
54 delete running;
55}
56
57void gameInput()
58{
59 int last = active_States.size() -1;
60 for( int i = 0;
61 i <= last;
62 i++ )
63 {
64 if( i == last )
65 active_States[i]->handleInput(true);
66 else
67 active_States[i]->handleInput(false);
68 }
69}
70
71void gameUpdate(float time_step)
72{
73 int last = active_States.size() -1;
74 for( int i = 0;
75 i <= last;
76 i++ )
77 {
78 if( i == last )
79 active_States[i]->update(time_step, true);
80 else
81 active_States[i]->update(time_step, false);
82 }
83}
84
85void gameDraw()
86{
87 int last = active_States.size() -1;
88 for( int i = 0;
89 i <= last;
90 i++ )
91 {
92 if( i == last )
93 active_States[i]->draw(true);
94 else
95 active_States[i]->draw(false);
96 }
97}