note mods

This commit is contained in:
Ralusama19 2017-01-22 14:57:45 +01:00
parent 446d07a8a2
commit 81f7b08d61
5 changed files with 27 additions and 3 deletions

View file

@ -20,7 +20,7 @@ Game* Game::i() {
// Main game loop
void Game::run() {
sf::Clock c;
sf::RenderWindow window(sf::VideoMode(W_WIDTH, W_HEIGHT), "( ( ( Radio Waves ) ) )", sf::Style::Close);
sf::RenderWindow window(sf::VideoMode(W_WIDTH, W_HEIGHT), "( ( ( Radio Wave ) ) )", sf::Style::Close);
window.setFramerateLimit(25);
window.setKeyRepeatEnabled(false);
float oldTime = c.getElapsedTime().asSeconds();

View file

@ -4,20 +4,26 @@ Player::Player(int num) : Actor(num) {
compas = Compas();
error = false;
time = 0;
mod = false;
}
Player::Player() : Actor() {
compas = Compas();
error = false;
time = 0;
mod = false;
}
bool Player::updateLogic(float deltaTime, sf::RenderWindow *window) {
time += deltaTime;
clock += deltaTime;
if (time > BLACKVALUE) {
compas.incraeseTime();
time = 0;
}
if (clock >= 89.15) clock = 0.0;
if (!mod && clock > 38.10 && clock < 64) mod = true;
else if (mod && clock < 38.10 || clock > 64) mod = false;
return false;
}
@ -25,8 +31,9 @@ bool Player::event(sf::Event e) {
switch(e.type) {
case (sf::Event::KeyPressed):
if(e.key.code == sf::Keyboard::C) {
std::string sample = "note"+std::to_string(rand()%4+1);
std::string sample = "mod"+std::to_string(rand()%4+1);
if(!mod) sample = "note"+std::to_string(rand()%4+1);
SoundManager::playSound(sample);
std::cout << "playing sample " << sample << std::endl;
compas.start();

View file

@ -11,10 +11,11 @@ public:
bool event(sf::Event e) final override;
protected:
bool updateLogic(float deltaTime, sf::RenderWindow *window);
private:
float time;
bool error;
bool mod;
float clock = 0.0;
};
#endif // PLAYER_H

View file

@ -47,6 +47,10 @@ sf::SoundBuffer SoundManager::bona5;
sf::SoundBuffer SoundManager::bona6;
sf::SoundBuffer SoundManager::bona7;
sf::SoundBuffer SoundManager::bona8;
sf::SoundBuffer SoundManager::mod1;
sf::SoundBuffer SoundManager::mod2;
sf::SoundBuffer SoundManager::mod3;
sf::SoundBuffer SoundManager::mod4;
std::map<std::string, sf::Sound> SoundManager::soundMap;
std::map<std::string, sf::Music> SoundManager::musicMap;
@ -136,6 +140,14 @@ void SoundManager::load(){
soundMap["bona7"].setBuffer(bona7);
ASSERT(bona8.loadFromFile(WORK_DIR+"Resources/Sounds/Bona/8.ogg"));
soundMap["bona8"].setBuffer(bona8);
ASSERT(mod1.loadFromFile(WORK_DIR+"Resources/Sounds/NotesMod/1.ogg"));
soundMap["mod1"].setBuffer(mod1);
ASSERT(mod2.loadFromFile(WORK_DIR+"Resources/Sounds/NotesMod/2.ogg"));
soundMap["mod2"].setBuffer(mod2);
ASSERT(mod3.loadFromFile(WORK_DIR+"Resources/Sounds/NotesMod/3.ogg"));
soundMap["mod3"].setBuffer(mod3);
ASSERT(mod4.loadFromFile(WORK_DIR+"Resources/Sounds/NotesMod/4.ogg"));
soundMap["mod4"].setBuffer(mod4);
}

View file

@ -67,6 +67,10 @@ class SoundManager {
static sf::SoundBuffer bona6;
static sf::SoundBuffer bona7;
static sf::SoundBuffer bona8;
static sf::SoundBuffer mod1;
static sf::SoundBuffer mod2;
static sf::SoundBuffer mod3;
static sf::SoundBuffer mod4;