Browse Source

Attempted to add sound FX. Added player melee, player abilities, death, and victory

master
Macoy Madson 5 years ago
parent
commit
6d17bccb05
  1. 2
      Jamrules
  2. BIN
      data/audio/death.ogg
  3. BIN
      data/audio/death2.ogg
  4. BIN
      data/audio/enemyMelee.ogg
  5. BIN
      data/audio/hit2.ogg
  6. BIN
      data/audio/level.ogg
  7. BIN
      data/audio/lightning.ogg
  8. BIN
      data/audio/playerHitFailure.ogg
  9. BIN
      data/audio/playerHitSuccess.ogg
  10. BIN
      data/audio/quietShaker.ogg
  11. BIN
      data/audio/victory.ogg
  12. 4
      src/Abilities.cpp
  13. 2
      src/Entity.cpp
  14. 18
      src/Game.hpp
  15. 19
      src/Gameplay.cpp
  16. 4
      src/PlayerDeadScreen.cpp
  17. 38
      src/main.cpp

2
Jamrules

@ -43,7 +43,7 @@ OPTIM = -O0 ;
HDRS = libs/base2.0 ;
LINKLIBS = -lsfml-graphics -lsfml-window -lsfml-system ;
LINKLIBS = -lsfml-audio -lsfml-graphics -lsfml-window -lsfml-system ;
KEEPOBJS = true ; # This doesn't actually fix anything, though it seems like it should
NOARSCAN = true ; # This actually fixes the problem

BIN
data/audio/death.ogg

Binary file not shown.

BIN
data/audio/death2.ogg

Binary file not shown.

BIN
data/audio/enemyMelee.ogg

Binary file not shown.

BIN
data/audio/hit2.ogg

Binary file not shown.

BIN
data/audio/level.ogg

Binary file not shown.

BIN
data/audio/lightning.ogg

Binary file not shown.

BIN
data/audio/playerHitFailure.ogg

Binary file not shown.

BIN
data/audio/playerHitSuccess.ogg

Binary file not shown.

BIN
data/audio/quietShaker.ogg

Binary file not shown.

BIN
data/audio/victory.ogg

Binary file not shown.

4
src/Abilities.cpp

@ -147,6 +147,8 @@ void LightningAbility::PlayerActivateWithTarget(int targetX, int targetY)
gameState.abilitiesUpdatingFx.push_back(this);
}
sfxLightning.play();
}
void LightningAbility::PlayerActivateNoTarget()
@ -272,6 +274,8 @@ void PhaseDoor::PlayerActivateNoTarget()
LOGD << "\tresult Phase door player " << gameState.player.X << ", " << gameState.player.Y;
LOGI << "You teleport to another place";
sfxPhaseDoor.play();
}
// Called every frame if Active

2
src/Entity.cpp

@ -463,6 +463,8 @@ void playerMeleeAttackEnemy(RLEntity* entity)
LOGI << "You hit the " << entity->Description.c_str() << " for " << abs(damage)
<< " damage";
sfxPlayerMeleeAttack.play();
}
}

18
src/Game.hpp

@ -2,6 +2,7 @@
#include "graphics/graphics.hpp"
#include "input/input.hpp"
#include "sound/sound.hpp"
#include <string>
@ -81,4 +82,19 @@ extern GameState gameState;
extern window win;
extern inputManager inp;
extern text displayText;
extern GameInput gameInp;
extern GameInput gameInp;
//
// Audio
//
extern sound sfxPlayerDead;
extern sound sfxPlayerVictory;
extern sound sfxPlayerMeleeAttack;
extern sound sfxPlayerMeleeMiss;
extern sound sfxLightning;
extern sound sfxPhaseDoor;
extern sound sfxEnemyMeleeAttack;
extern sound sfxNextLevel;

19
src/Gameplay.cpp

@ -313,6 +313,11 @@ bool PlayGame()
TurnCounter++;
LOGI << "You step through to the next level";
if (gameState.currentLevel > NUM_LEVELS_TO_WIN)
sfxPlayerVictory.play();
else
sfxNextLevel.play();
LOGD << "Cheat: Next Level";
continue;
@ -457,7 +462,8 @@ bool PlayGame()
playerSwappedForAbility = "Swapped ";
playerSwappedForAbility += lastAbilityName;
playerSwappedForAbility += " for ";
playerSwappedForAbility += gameState.player.Abilities[abilityIndex]->Name.c_str();
playerSwappedForAbility +=
gameState.player.Abilities[abilityIndex]->Name.c_str();
playerTurnPerformed = true;
if (!enemy->DroppedAbility)
@ -584,7 +590,8 @@ bool PlayGame()
if (!entitiesAtPosition.empty())
{
standingOnDisplay += "You stomp on ";
standingOnDisplay += describePosition(gameState.player.X, gameState.player.Y);
standingOnDisplay +=
describePosition(gameState.player.X, gameState.player.Y);
std::string abilityDescription;
if (playerCanSwapAbilityNow(&abilityDescription))
@ -617,6 +624,9 @@ bool PlayGame()
TurnCounter++;
LOGI << "You step through to the next level";
if (gameState.currentLevel > NUM_LEVELS_TO_WIN)
sfxPlayerVictory.play();
gameState.player.LevelUp();
// This is probably unnecessary
@ -794,8 +804,9 @@ bool PlayGame()
static std::string lookModeCursorText(LOOK_MODE_CURSOR);
displayText.setText(lookModeCursorText);
displayText.setColor(LOOK_CURSOR_COLOR);
displayText.setPosition(TileTextWidth * (lookModeCursor.X - camXOffset),
TileTextHeight * ((lookModeCursor.Y - camYOffset) + ViewTileTopMargin));
displayText.setPosition(
TileTextWidth * (lookModeCursor.X - camXOffset),
TileTextHeight * ((lookModeCursor.Y - camYOffset) + ViewTileTopMargin));
win.draw(&displayText);
}

4
src/PlayerDeadScreen.cpp

@ -9,9 +9,13 @@
#include "Game.hpp"
#include "Utilities.hpp"
#include "sound/sound.hpp"
// returns whether or not to restart the game
bool PlayerDeadScreen()
{
sfxPlayerDead.play();
while (!win.shouldClose() && !inp.isPressed(inputCode::Return) &&
!inp.isPressed(inputCode::Escape))
{

38
src/main.cpp

@ -9,13 +9,13 @@
#include "Game.hpp"
#include "GameInput.hpp"
#include "Gameplay.hpp"
#include "Globals.hpp"
#include "Levels.hpp"
#include "RLMap.hpp"
#include "Utilities.hpp"
#include "Globals.hpp"
#include "PlayerDeadScreen.hpp"
#include "MainMenu.hpp"
#include "PlayerDeadScreen.hpp"
int TurnCounter = 0;
@ -72,6 +72,38 @@ GameInput gameInp(inp);
static gv::Logging::Logger s_GameLogger(gv::Logging::Severity::debug, &ConsoleAndGameLogOutput);
sound sfxPlayerDead;
sound sfxPlayerVictory;
sound sfxPlayerMeleeAttack;
sound sfxPlayerMeleeMiss;
sound sfxLightning;
sound sfxPhaseDoor;
sound sfxEnemyMeleeAttack;
sound sfxNextLevel;
void loadAudio()
{
if (!sfxPlayerDead.load("data/audio/death.ogg"))
LOGE << "Failed to load sfxPlayerDead";
if (!sfxPlayerVictory.load("data/audio/victory.ogg"))
LOGE << "Failed to load sfxPlayerVictory";
if (!sfxPlayerMeleeAttack.load("data/audio/quietShaker.ogg"))
LOGE << "Failed to load sfxPlayerMeleeAttack";
if (!sfxPlayerMeleeMiss.load("data/audio/quietShaker.ogg"))
LOGE << "Failed to load sfxPlayerMeleeMiss";
if (!sfxLightning.load("data/audio/quietShaker.ogg"))
LOGE << "Failed to load sfxLightning";
if (!sfxPhaseDoor.load("data/audio/quietShaker.ogg"))
LOGE << "Failed to load sfxPhaseDoor";
if (!sfxEnemyMeleeAttack.load("data/audio/hit2.ogg"))
LOGE << "Failed to load sfxEnemyMeleeAttack";
if (!sfxNextLevel.load("data/audio/level.ogg"))
LOGE << "Failed to load sfxNextLevel";
}
void initializeWindow(window& win)
{
win.setBackgroundColor(WIN_BACKGROUND_COLOR);
@ -100,6 +132,8 @@ int main(int argc, char const* argv[])
displayText.setSize(TileTextHeight);
displayText.setColor(WALL_TILE_COLOR_NORMAL);
loadAudio();
bool shouldPlay = MainMenu();
if (!shouldPlay)

Loading…
Cancel
Save