00001 #include "Application.h" 00002 00011 Application::Application() : 00012 _running(true) 00013 { 00014 // empty 00015 } 00016 00017 Application::~Application() 00018 { 00019 00020 } 00021 00023 void Application::changeState(GameState* gs) 00024 { 00025 vector<GameState*>::iterator iter; 00026 for (iter = _states.begin(); iter != _states.end(); iter++) 00027 { 00028 SAFE_DELETE(*iter); 00029 } 00030 00031 _states.push_back(gs); 00032 } 00033 00034 void Application::pushState(GameState* gs) 00035 { 00036 _states.push_back(gs); 00037 } 00038 00039 00040 void Application::popState() 00041 { 00042 GameState* gs = _states.back(); 00043 _states.pop_back(); 00044 gs->deinit(); 00045 SAFE_DELETE(gs); 00046 } 00047 00048 bool const Application::running() 00049 { 00050 return _running; 00051 } 00052 00053 void Application::quit() 00054 { 00055 _running = false; 00056 } 00057 00058 GameState* Application::getCurrentGameState() 00059 { 00060 return _states.back(); 00061 } 00062 00063 void Application::popAllStates() 00064 { 00065 int size = static_cast<int>(_states.size()); 00066 for (int i = 0; i < size; i++) 00067 { 00068 popState(); 00069 } 00070 }