[Added] Pause and Game Over screens

This commit is contained in:
Ninjaws
2024-12-11 23:20:10 +01:00
parent 7bdd8829b0
commit 770d3e3c71
10 changed files with 275 additions and 25 deletions
+3 -3
View File
@@ -35,7 +35,7 @@ MainScreen::MainScreen()
AudioService::getInstance().playMusic();
}
InputService::getInstance().setKeysToWatch({KEY_ENTER, KEY_UP, KEY_DOWN}, {MOUSE_BUTTON_LEFT});
InputService::getInstance().setKeysToWatch({KEY_ENTER, KEY_W, KEY_S}, {MOUSE_BUTTON_LEFT});
}
void MainScreen::logic()
@@ -81,11 +81,11 @@ void MainScreen::mouseLogic()
void MainScreen::keyboardLogic()
{
if (InputService::getInstance().isKeyPressed(KEY_DOWN) || InputService::getInstance().isKeyPressed(KEY_UP))
if (InputService::getInstance().isKeyPressed(KEY_S) || InputService::getInstance().isKeyPressed(KEY_W))
{
buttons[hoveredButton].setColor(WHITE);
/** Move up or down depending on the pressed button. +4 is used so that -1 becomes 3 (the last button) */
hoveredButton = ((hoveredButton - (InputService::getInstance().isKeyPressed(KEY_DOWN) ? -1 : 1)) + 4) % 4;
hoveredButton = ((hoveredButton - (InputService::getInstance().isKeyPressed(KEY_S) ? -1 : 1)) + 4) % 4;
buttons[hoveredButton].setColor(RED);
}
}
+1 -1
View File
@@ -17,7 +17,7 @@ void AssetService::setAssets()
music[EMusic::MAIN] = loadMusic("Audio/Music/Crash_WarpRoomTheme.ogg", true);
music[EMusic::GAME] = loadMusic("Audio/Music/GameTheme_2.ogg", true);
music[EMusic::GAME_OVER] = loadMusic("Audio/Music/gameOverTheme.ogg", false);
music[EMusic::GAME_OVER] = loadMusic("Audio/Music/gameOverTheme_2.ogg", false);
/** Todo: set volume */
backgrounds[EBackground::TUTORIAL] = loadTexture("Textures/TutorialBackground2.png");
+1
View File
@@ -13,6 +13,7 @@ void AudioService::setMusic(EMusic music)
if (currentTrack == music)
return;
stopMusic(); // Makes sure it doesn't continue where it left off
this->currentTrack = music;
this->music = AssetService::getInstance().getMusic(music);
}
+4
View File
@@ -4,6 +4,7 @@
#include "screens/MainScreen.h"
#include "screens/TutorialScreen.h"
#include "screens/GameScreen.h"
#include "screens/GameOverScreen.h"
#include <optional>
#include "services/AudioService.h"
#include "services/InputService.h"
@@ -24,6 +25,9 @@ void StateService::setScreen(EScreen state)
case EScreen::GAME:
currentScreen = std::make_unique<GameScreen>();
break;
// case EScreen::GAMEOVER:
// currentScreen = std::make_unique<GameOverScreen>();
// break;
case EScreen::CLOSE:
gameRunning = false;
break;