diff --git a/include/PopupWindow.h b/include/PopupWindow.h index e09d9b1..bd48c32 100644 --- a/include/PopupWindow.h +++ b/include/PopupWindow.h @@ -25,8 +25,6 @@ private: SDL_Window* window; SDL_Texture* texture; bool continueGame; - - }; diff --git a/src/Game.cpp b/src/Game.cpp index d7c580f..6c28ee9 100644 --- a/src/Game.cpp +++ b/src/Game.cpp @@ -276,9 +276,8 @@ void Game::refreshPlayers() { for(auto& p : projectiles) p->destroy(); - - player.getComponent().position.x = 80; - player.getComponent().position.y = 80; + player.getComponent().position = Vector2D(80, 80); + enemy.getComponent().position = Vector2D(600, 500); player.getComponent().setHealth(5); enemy.getComponent().setHealth(5); diff --git a/src/PopupWindow.cpp b/src/PopupWindow.cpp index 185d069..109313e 100644 --- a/src/PopupWindow.cpp +++ b/src/PopupWindow.cpp @@ -34,18 +34,23 @@ void PopupWindow::handleWinnerEvents() { { continueGame = false; interacted = true; + return; } - else if (e.type == SDL_KEYDOWN) - { - if (e.key.keysym.sym == SDLK_c) - { - continueGame = true; - interacted = true; - } - else if (e.key.keysym.sym == SDLK_q) - { + + if(e.type != SDL_KEYDOWN) + continue; + + switch (e.key.keysym.sym) { + + case SDLK_q: { continueGame = false; interacted = true; + break; + } + case SDLK_c: { + continueGame = true; + interacted = true; + break; } } } @@ -59,6 +64,7 @@ void PopupWindow::renderWinnerPopup(bool winner) { SDL_RenderClear(this->renderer); + //Maybe use texture manager (changes need to be made that it does not use game::renderer automatically, but receives one instead) this->texture = winner ? IMG_LoadTexture(this->renderer, "assets/Player1Victory.png") : IMG_LoadTexture(this->renderer, "assets/Player2Victory.png"); diff --git a/src/main.cpp b/src/main.cpp index 7cb30c3..fc9ce82 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -18,7 +18,6 @@ int main(int argc, char* argv[]) game->init("No_Name_Chicken_Game", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, SCREEN_SIZE_WIDTH, SCREEN_SIZE_HEIGHT, false); while(playing) { - std::cout << "djslfsldkfj" << std::endl; while (game->running()) { frameStart = SDL_GetTicks();