diff --git a/VaporWaveWars/character.cpp b/VaporWaveWars/character.cpp index 4640424..34346bf 100644 --- a/VaporWaveWars/character.cpp +++ b/VaporWaveWars/character.cpp @@ -53,6 +53,9 @@ void Character::setState(PlayerState::playerState state){ idleFrame = indexX; indexX = 0; indexY = 1 + magicNumber; + std::string sample = "atk"+std::to_string(rand()%20+1); + SoundManager::playSound(sample); + std::cout << "playing sample " << sample << std::endl; } else if (false /*state == PlayerState::damaged*/){ indexX = 0; diff --git a/VaporWaveWars/combat.cpp b/VaporWaveWars/combat.cpp index 6ea3627..3d1155d 100644 --- a/VaporWaveWars/combat.cpp +++ b/VaporWaveWars/combat.cpp @@ -8,7 +8,6 @@ Combat::Combat() { // enemy = new IaEnemy(1); enemy = new Player(1); initShader(); - SoundManager::load(); SoundManager::playMusic("music"); } diff --git a/VaporWaveWars/commons.hpp b/VaporWaveWars/commons.hpp index 56bd793..e23f46b 100644 --- a/VaporWaveWars/commons.hpp +++ b/VaporWaveWars/commons.hpp @@ -6,11 +6,12 @@ #include #include #include /* getenv */ +#include /* srand, rand */ +#include /* time */ #include #include - +#include "soundmanager.hpp" const int SCENE_NUM = 4; - #define MARGEERR 0.05f #define BLACKVALUE 0.60f #define W_WIDTH 800 @@ -27,21 +28,21 @@ const std::string WORK_DIR(getenv("WORK_DIR")); assert(expression); \ std::exit(-1); \ } \ -} while (0) + } while (0) namespace ButtonState { //namespace for button states (for the menu) //released is the regular state of the button, it activates when you move the mouse over it //off means it is drawn but not clickable. - enum basicState {released, active, pressed, off}; +enum basicState {released, active, pressed, off}; } namespace GameScene { - enum gameScene{menu,inGame,help,credits}; +enum gameScene{menu,inGame,help,credits}; } namespace PlayerState { - enum playerState{idle, attacking, inMidle}; +enum playerState{idle, attacking, inMidle}; } #endif // COMMONS_HPP diff --git a/VaporWaveWars/main.cpp b/VaporWaveWars/main.cpp index bf0efb6..407db7a 100644 --- a/VaporWaveWars/main.cpp +++ b/VaporWaveWars/main.cpp @@ -1,6 +1,7 @@ #include "mygame.hpp" #include "compas.hpp" int main() { + srand (time(NULL)); MyGame game; game.run(); return 0; diff --git a/VaporWaveWars/mygame.cpp b/VaporWaveWars/mygame.cpp index b7fda60..3608816 100644 --- a/VaporWaveWars/mygame.cpp +++ b/VaporWaveWars/mygame.cpp @@ -9,6 +9,7 @@ MyGame::MyGame() { _scenes[GameScene::help] = _menu; _scenes[GameScene::credits] = _menu; std::cout << "in menu" << std::endl; + SoundManager::load(); } MyGame::~MyGame() {