2 * Copyright (C) 2008 Patrik Gornicz, Gornicz_P (at) hotmail (dot) com.
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #include "entityCreator.h"
25 #include "effectManager.h"
27 #include "GameStates/GameState.h"
28 #include "GameStates/Running.h"
29 #include "GameStates/Paused.h"
30 #include "GameStates/CreatingPolygon.h"
33 /// ***** Private Variables *****
35 // The stack of active game states
36 vector<GameState*> active_States;
38 // Pointers to each possible game state
39 // inserted and removed from the active_States
42 CreatingPolygon* creating_Polygon;
44 // true if the top state requested itself to be poped
46 // pointer to a state wishing to be added
47 GameState* push_State;
50 /// ***** Public Methods *****
54 running = new Running();
55 paused = new Paused();
56 creating_Polygon = new CreatingPolygon();
61 // create starting entities
64 active_States.push_back(running);
68 DPF(0, "World Created");
77 delete creating_Polygon;
82 void game::handleInput()
84 creator::handleInput();
86 int last = active_States.size() -1;
88 if(active_States[last] != running && running->pushMe())
93 if(active_States[last] != paused && paused->pushMe())
98 if(active_States[last] != creating_Polygon && creating_Polygon->pushMe())
100 push_State = creating_Polygon;
110 if(active_States[i]->popMe())
113 active_States[i]->handleInput(true);
116 active_States[i]->handleInput(false);
120 void game::update(float time_step)
124 active_States.pop_back();
128 if(push_State != NULL)
130 active_States.push_back(push_State);
134 int last = active_States.size() -1;
140 active_States[i]->update(time_step, true);
142 active_States[i]->update(time_step, false);
148 int last = active_States.size() -1;
154 active_States[i]->draw(true);
156 active_States[i]->draw(false);