void GameApplication::gameLoop(){ loadStatsFile(); musicVolumeControl(); while (!quit) { while (SDL_PollEvent(&e) != 0) { if (e.type == SDL_QUIT) { quit = true; } if (e.type == SDL_KEYDOWN) { if (e.key.keysym.sym == SDLK_BACKSPACE) { if (board.isStarted() && !endOfTheGame()) { undo(); } } } for (int i = 0; i < NUMBER_OF_BUTTON; ++i) { if (lockButtons) { temp[2] = button[2].handleEvent(e); temp[3] = button[3].handleEvent(e); } else { temp[i] = button[i].handleEvent(e); } } for (int i = 0; i < NUMBER_OF_TILE * 4; i++) { choice = tile[i].handleEvent(e, coordI, coordJ); if (choice == true) { mark++; if (!board.pile[coordI][coordJ].empty()) { takePair(); break; } else { choice = false; } } } } logicButtons(temp); logicBoard(); drowGame(board); } }
int main(int argc, char* args[]) { bool temp[NUMBER_OF_BUTTON] = { false }; bool quit = false; SDL_Event e; if (!init()) { printf("Failed to initialize!\n"); } else { if (!loadMedia()) { printf("Failed to load media!\n"); } else { loadStatsFile(); musicVolumeControl(); while (!quit) { while (SDL_PollEvent(&e) != 0) { if (e.type == SDL_QUIT) { quit = true; } if(e.type == SDL_KEYDOWN) { if(e.key.keysym.sym == SDLK_BACKSPACE) { if(board.isStarted() && !endOfTheGame()) { undo(); } } } for (int i = 0; i < NUMBER_OF_BUTTON; ++i) { if(lockButtons) { temp[2] = gButton[2].handleEvent(e); temp[3] = gButton[3].handleEvent(e); } else { temp[i] = gButton[i].handleEvent(e); } } for (int i = 0; i < NUMBER_OF_TILE * 4; i++) { choice = gTile[i].handleEvent(e, coordI, coordJ); if (choice == true) { mark++; if (!board.pile[coordI][coordJ].empty()) { takePair(); break; } else { choice = false; } } } } logicButtons(temp); logicBoard(); drowGame(board); } } } close(); return 0; }