/* Do basic initialization, get the loop going */ #include "gamestate.h" #include "game.h" #include int main(int argc, char** argv) { // Barebones setup for our game if (SDL_Init(SDL_INIT_EVERYTHING) < 0) return false; SDL_WM_SetCaption("TreeWars","TreeWars"); stack state_stack; // initialize the stack by initting and pushing the initial state(s) GameState* tmpstate = new Game(); if (!tmpstate->init()) exit(1); state_stack.push(tmpstate); while (!state_stack.empty()) { GameState* state = state_stack.top(); try { state->execute(state_stack); } catch (StateExit& e) { // remove the old state state_stack.pop(); delete state; // init the new state, discarding it if we fail while (!(state_stack.empty() || state_stack.top()->init())) { state_stack.pop(); delete state; } } } SDL_Quit(); return 0; }