Merge branch 'master' of github.com:ralucado/WaveGGJ17

This commit is contained in:
marti.lloveras 2017-01-22 15:04:18 +01:00
commit 0f71a52a50
8 changed files with 19 additions and 3 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

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

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()%2+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,8 @@ sf::SoundBuffer SoundManager::bona5;
sf::SoundBuffer SoundManager::bona6;
sf::SoundBuffer SoundManager::bona7;
sf::SoundBuffer SoundManager::bona8;
sf::SoundBuffer SoundManager::mod1;
sf::SoundBuffer SoundManager::mod2;
std::map<std::string, sf::Sound> SoundManager::soundMap;
std::map<std::string, sf::Music> SoundManager::musicMap;
@ -136,6 +138,10 @@ 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);
}

View file

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