int main (int argc, char * argv[]) { Window::getInstance()->create(1366, 768, "inspector gadget!", true); Input * input = Input::getInstance(); if(ifstream("data/preferences.ini")) input->loadKeymapping("data/preferences.ini"); else { input->addMapping("escape", SDLK_ESCAPE); input->addMapping("enter", SDLK_RETURN); input->addMapping("up", SDLK_UP); input->addMapping("down", SDLK_DOWN); input->addMapping("left", SDLK_LEFT); input->addMapping("right", SDLK_RIGHT); input->saveKeymapping("data/preferences.ini"); } StateManager * stateman = StateManager::getInstance(); stateman->changeState(new state::GameState()); stateman->run(); std::cout << "bye\n"; return 0; }
int main( int argc, char* args[] ) { //Start SDL SDL_Init( SDL_INIT_EVERYTHING ); //Set up screen SDL_Surface* screen = NULL; screen = SDL_SetVideoMode( WINWIDTH, WINHEIGHT, 32, SDL_SWSURFACE ); SDL_WM_SetCaption("Squids of the Galaxy", NULL); //State Mananger StateManager* stateManager = StateManager::Instance(); //Create main menu MainMenuState* mainMenu = new MainMenuState(); stateManager->changeState(mainMenu); //Main game loop while (stateManager->isRunning()) { //USER INPUT while (SDL_PollEvent(&event)) { if (event.type == SDL_QUIT) stateManager->quit(); //Take user input stateManager->userInput(&event); } //UPDATE stateManager->update(); //RENDER stateManager->display(screen); if (SDL_Flip(screen) == -1) return 1; } //Quit SDL SDL_Quit(); return 0; }