added sound buffers

This commit is contained in:
Ralusama19 2017-01-21 14:29:08 +01:00
parent 66377e60ee
commit cc0d1e80eb
5 changed files with 12 additions and 7 deletions

View file

@ -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;

View file

@ -8,7 +8,6 @@ Combat::Combat() {
// enemy = new IaEnemy(1);
enemy = new Player(1);
initShader();
SoundManager::load();
SoundManager::playMusic("music");
}

View file

@ -6,11 +6,12 @@
#include <SFML/Graphics.hpp>
#include <assert.h>
#include <stdlib.h> /* getenv */
#include <stdlib.h> /* srand, rand */
#include <time.h> /* time */
#include <iostream>
#include <string>
#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

View file

@ -1,6 +1,7 @@
#include "mygame.hpp"
#include "compas.hpp"
int main() {
srand (time(NULL));
MyGame game;
game.run();
return 0;

View file

@ -9,6 +9,7 @@ MyGame::MyGame() {
_scenes[GameScene::help] = _menu;
_scenes[GameScene::credits] = _menu;
std::cout << "in menu" << std::endl;
SoundManager::load();
}
MyGame::~MyGame() {