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