Compare commits

..

26 commits

Author SHA1 Message Date
Ralusama19
bf5ef39233 stuff 2017-01-22 17:00:37 +01:00
Ralusama19
25a38c6b08 notes mod fixed 2017-01-22 16:53:46 +01:00
Ralusama19
f096594e0e Merge branch 'master' of github.com:ralucado/WaveGGJ17 2017-01-22 15:41:13 +01:00
Ralusama19
e6ce69e20a added zip file 2017-01-22 15:41:03 +01:00
marti.lloveras
6e89ff96f5 image Guai 2017-01-22 15:25:32 +01:00
marti.lloveras
0f71a52a50 Merge branch 'master' of github.com:ralucado/WaveGGJ17 2017-01-22 15:04:18 +01:00
marti.lloveras
3f00905906 memes 2017-01-22 15:04:13 +01:00
Ralusama19
c762484669 update note mods 2017-01-22 15:04:03 +01:00
Ralusama19
41ef88d6cb Merge branch 'master' of github.com:ralucado/WaveGGJ17 2017-01-22 14:57:50 +01:00
Ralusama19
81f7b08d61 note mods 2017-01-22 14:57:45 +01:00
serk
1023691e2d perfect => +1 score 2017-01-22 14:31:57 +01:00
serk
446d07a8a2 Merge branch 'master' of https://github.com/ralucado/WaveGGJ17 2017-01-22 14:02:38 +01:00
serk
71c249426b hour fix 2017-01-22 14:02:23 +01:00
Ralusama19
51be693444 new mastered sounds 2017-01-22 05:26:59 +01:00
Ralusama19
aff857b33c portada cropped fix 2017-01-22 05:16:33 +01:00
Ralusama19
736124743a portada cropped 2017-01-22 05:14:03 +01:00
Ralusama19
cefaf2f00c Merge branch 'master' of github.com:ralucado/WaveGGJ17 2017-01-22 05:09:48 +01:00
Ralusama19
e0fa95a460 portada resize 2017-01-22 05:09:44 +01:00
serk
0a589d6a11 Merge branch 'master' of https://github.com/ralucado/WaveGGJ17 2017-01-22 05:08:12 +01:00
serk
5e8d22d51e time diversifasdasdsad 2017-01-22 05:03:56 +01:00
Ralusama19
fa3d3bd90c Merge branch 'master' of github.com:ralucado/WaveGGJ17 2017-01-22 04:57:01 +01:00
Ralusama19
b7a972c232 portada 2017-01-22 04:56:53 +01:00
marti.lloveras
aa513cbcc2 Marge error = 0.25 2017-01-22 04:41:01 +01:00
Ralusama19
469b40f6f6 removed mp3 and wavs 2017-01-22 04:28:45 +01:00
Ralusama19
f5f0ae945a sons de trrring 2017-01-22 04:26:07 +01:00
marti.lloveras
e6234333a6 aligned wave 2017-01-22 03:01:10 +01:00
104 changed files with 198 additions and 201 deletions

BIN
Radio Wave.zip Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 736 KiB

BIN
Resources/Sounds/Bona/1.ogg Normal file

Binary file not shown.

BIN
Resources/Sounds/Bona/2.ogg Normal file

Binary file not shown.

BIN
Resources/Sounds/Bona/3.ogg Normal file

Binary file not shown.

BIN
Resources/Sounds/Bona/4.ogg Normal file

Binary file not shown.

BIN
Resources/Sounds/Bona/5.ogg Normal file

Binary file not shown.

BIN
Resources/Sounds/Bona/6.ogg Normal file

Binary file not shown.

BIN
Resources/Sounds/Bona/7.ogg Normal file

Binary file not shown.

BIN
Resources/Sounds/Bona/8.ogg Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Resources/Sounds/clicks.ogg Normal file

Binary file not shown.

Binary file not shown.

BIN
Resources/Sounds/intro.ogg Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
Resources/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 KiB

BIN
Resources/portada.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 744 KiB

BIN
Resources/portada.xcf Normal file

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View file

@ -1,5 +1,6 @@
uniform vec2 resolution;
uniform float time;
uniform float hour;
float rand(vec2 n) {
return fract(sin(dot(n, vec2(12.9898, 4.1414))) * 43758.5453);
@ -36,8 +37,10 @@ void main(void) {
if (uv.y < umuv.y) uv.y += abs(time * 0.1);
else uv.y -= abs(time * 0.1);
vec4 color = vec4(255, 120, 153, 255) / 255.;
vec4 colorB = vec4(255,255,255,255)/ 255.;
vec3 colorPink = vec3(255.,0.,255.);
vec3 colorBlue = vec3(0.,255.,255.);
vec4 color = vec4(((colorBlue.x*hour) + (colorPink.x*(1.-hour)))/2.,
((colorBlue.y*hour) + (colorPink.y*(1.-hour)))/2.,
((colorBlue.z*hour) + (colorPink.z*(1.-hour)))/2., 255) / 255.;
gl_FragColor = (grid(fract(uv))) * color - line(umuv.y, 0., 0.175, 0.025) * color * 2.;
}

View file

@ -35,8 +35,8 @@ bool Actor::update(float deltaTime, sf::RenderWindow *window) {
bool Actor::hitBy(Compas enemy) {
bool dodge = enemy == compas;
if (dodge) std::cout << "dodge" << std::endl;
else std::cout << "hit" << std::endl;
/*if (dodge) //std::cout << "dodge" << std::endl;
else //std::cout << "hit" << std::endl;*/
if (!dodge) {
character->setState(PlayerState::hurt);
animate = PlayerState::inMidle;

View file

@ -15,7 +15,6 @@ public:
bool hitBy(Compas enemy);
Compas getAttack() const;
virtual bool event(sf::Event e) = 0;
virtual DefenseResult::defenseResult event(sf::Event e, int note) = 0;
protected:
Compas compas;

View file

@ -25,7 +25,7 @@ int Button::getClicks(){
int c = _clicks;
//cout << "popping clicks " << c << endl;
_clicks = 0;
//if (_clicks > 0) std::cout << "popclicks = " << _clicks << std::endl;
//if (_clicks > 0) //std::cout << "popclicks = " << _clicks << std::endl;
return c;
}
@ -51,14 +51,14 @@ void Button::handleMouseEvent(sf::Event& event){
switch (event.type){
case (sf::Event::MouseButtonPressed):
if(_state == ButtonState::active) _state = ButtonState::pressed;
//std::cout << "pressed!" << _clicks << std::endl;
////std::cout << "pressed!" << _clicks << std::endl;
break;
case (sf::Event::MouseButtonReleased):
if(_state == ButtonState::pressed){
_state = ButtonState::active;
++_clicks;
//std::cout << "released!" << _clicks << std::endl;
////std::cout << "released!" << _clicks << std::endl;
}
break;

View file

@ -51,23 +51,30 @@ void Character::setState(PlayerState::playerState state){
indexX = 0;
indexY = 1 + magicNumber;
std::string sample = "atk"+std::to_string(rand()%20+1);
SoundManager::setVolume(100,sample);
SoundManager::playSound(sample);
//std::cout << "playing sample " << sample << std::endl;
////std::cout << "playing sample " << sample << std::endl;
}
else if (state == PlayerState::hurt){
std::cout << "i am hurt" << std::endl;
////std::cout << "i am hurt" << std::endl;
indexX = 0;
indexY = 2 + magicNumber;
std::string sample = "fail"+std::to_string(rand()%6+1);
SoundManager::setVolume(100,sample);
SoundManager::playSound(sample);
//std::cout << "playing sample " << sample << std::endl;
////std::cout << "playing sample " << sample << std::endl;
}
else if (state == PlayerState::success){
std::cout << "i am succeed!" << std::endl;
////std::cout << "i am succeed!" << std::endl;
indexX = 0;
indexY = 3 + magicNumber;
//std::string sample = "succeed"+std::to_string(rand()%6+1);
//SoundManager::playSound(sample);
std::string sample = "bona"+std::to_string(rand()%8+1);
SoundManager::setVolume(10,sample);
SoundManager::playSound(sample);
//std::cout << "playing sample " << sample << std::endl;
}
}

View file

@ -4,8 +4,6 @@ Combat::Combat() {
ia = false;
// ia = true;
state = CombatState::player_atk;
readingCompas = false;
readCompas = 0;
player = new Player(0);
// enemy = new IaEnemy(1);
enemy = new Player(1);
@ -35,8 +33,6 @@ Combat::Combat(bool ia) {
if (ia) enemy = new IaEnemy(1);
else enemy = new Player(1);
initShader();
readingCompas = false;
readCompas = 0;
}
bool Combat::isAttack() const {
@ -65,13 +61,25 @@ void Combat::updateHalo() {
}
float isNight() {
time_t rawtime;
struct tm * ptm;
time ( &rawtime );
ptm = gmtime ( &rawtime );
float hour = (float ((ptm->tm_hour+UTC)%24))/(23.);
float result = (std::cos(hour*(2*PI)) + 1.f)/2.;
return result;
}
void Combat::initShader() {
time = 0;
aux = 0;
_text.create(W_WIDTH, W_HEIGHT);
_background.setTexture(_text);
_shader.loadFromFile(WORK_DIR+"Resources/shader.frag", sf::Shader::Fragment);
_shader.setParameter("resolution", sf::Vector2f(W_WIDTH, W_HEIGHT));
_shader.setParameter("time", time);
_shader.setParameter("hour", isNight());
ASSERT(_haloT.loadFromFile(WORK_DIR+"Resources/platform-halo.png"));
_halo.setTexture(_haloT);
@ -90,7 +98,7 @@ void Combat::initShader() {
void Combat::update(float deltaTime, sf::RenderWindow *window) {
player->update(deltaTime, window);
bool aux = enemy->update(deltaTime, window);
if (ia); //enemyManager(aux); //end of player two ia rythm
if (ia) enemyManager(aux); //end of player two ia rythm
time += deltaTime;
_shader.setParameter("time", time);
@ -144,90 +152,65 @@ void Combat::draw(sf::RenderWindow *window) {
}
void Combat::updateEvents(sf::Event e) {
if (isPlayerOne() or !ia) {
enemyManager(e);
if (isPlayerOne()) {
bool compasFinish = !player->event(e);
enemyManager(compasFinish);
if(e.type == sf::Event::KeyPressed && e.key.code == sf::Keyboard::C && !isAttack()) doMahWaves(!isPlayerOne());
}
else if (!ia) {
bool compasFinish = !enemy->event(e);
enemyManager(compasFinish);
if(e.type == sf::Event::KeyPressed && e.key.code == sf::Keyboard::C && !isAttack()) doMahWaves(!isPlayerOne());
}
}
void Combat::enemyManager(sf::Event e) { //To do: considerar si hay ia
if(e.type == sf::Event::KeyPressed && e.key.code == sf::Keyboard::C && !isAttack()) doMahWaves(!isPlayerOne());
void Combat::enemyManager(bool compasFinish) { //To do: considerar si hay ia
if(compasFinish) {
Compas compas;
Compas compas;
switch(state) {
case CombatState::player_def:
if(!readingCompas) {
readingCompas = true;
readCompas = 0;
std::cout << "Start reading pink defense" << std::endl;
}
compas = enemy->getAttack();
if(readCompas == compas.size()) {
state = CombatState::player_atk;
readingCompas = false;
}
else {
std::cout << "Reading note " << readCompas << " out of " << compas.size() << std::endl;
DefenseResult::defenseResult defense = player->event(e, compas.get(readCompas));
if(defense == DefenseResult::fail) {
switch(state) {
case CombatState::player_def:
compas = enemy->getAttack();
if(!player->hitBy(compas)) {
scoreEnemy->incrisScore();
state = CombatState::player_atk;
readingCompas = false;
}
else if(defense == DefenseResult::success) {
++readCompas;
else {
scorePlayer->incrisScore();
}
}
break;
case CombatState::player_atk:
if(!player->event(e)) {
state = CombatState::player_atk;
break;
case CombatState::player_atk:
compas = player->getAttack();
if(compas.isFailed()) {
state = CombatState::enemy_atk;
}
else state = CombatState::enemy_def;
}
break;
case CombatState::enemy_def:
if(!readingCompas) {
readingCompas = true;
readCompas = 0;
std::cout << "Start reading blue defense" << std::endl;
}
compas = player->getAttack();
if(readCompas < compas.size()) {
std::cout << "Reading note " << readCompas << " out of " << compas.size() << std::endl;
DefenseResult::defenseResult defense = enemy->event(e, compas.get(readCompas));
if(defense == DefenseResult::fail) {
break;
case CombatState::enemy_def:
compas = player->getAttack();
if(!enemy->hitBy(compas)) {
scorePlayer->incrisScore();
state = CombatState::enemy_atk;
readingCompas = false;
}
else if(defense == DefenseResult::success) {
++readCompas;
else {
scoreEnemy->incrisScore();
}
}
else {
state = CombatState::enemy_atk;
readingCompas = false;
}
break;
case CombatState::enemy_atk:
if(!enemy->event(e)) {
break;
case CombatState::enemy_atk:
compas = enemy->getAttack();
if(compas.isFailed()) {
state = CombatState::player_atk;
}
else state = CombatState::player_def;
}
break;
default:
break;
break;
default:
break;
}
}
}
void Combat::doMahWaves(bool p) {
std::cout << "defensa jugador " << p << std::endl;
//std::cout << "defensa jugador " << p << std::endl;
std::vector<int> notes;
if(p){
notes = player->getAttack().getNotes();
@ -238,11 +221,11 @@ void Combat::doMahWaves(bool p) {
if(!p) anterior = 256+256*anterior;
else anterior = 768-256*anterior;
for(int i = 0; i < notes.size(); ++i){
std::cout << notes[i] << std::endl;
//std::cout << notes[i] << std::endl;
Wave* w = new Wave(p);
//if(!p) w->setPosition(anterior,500);
//else w->setPosition(512-512*anterior,500);
w->setPosition(anterior,W_HEIGHT/2);
w->setPosition(anterior,W_HEIGHT/2 + 17);
if(i<notes.size()) {
if(!p) anterior += 176*notes[i+1];
else anterior -= 176*notes[i+1];
@ -254,7 +237,7 @@ void Combat::doMahWaves(bool p) {
// if(!p) anterior = 512+256*anterior;
// else anterior = 512-256*anterior;
// for(int i = 0; i < 20; ++i){
// //std::cout << 0 << std::endl;
// ////std::cout << 0 << std::endl;
// Wave* w = new Wave(p);
// //if(!p) w->setPosition(anterior,500);
// //else w->setPosition(512-512*anterior,500);

View file

@ -10,6 +10,11 @@
#include "soundmanager.hpp"
#include "score.hpp"
#include "wave.hpp"
#include <time.h>
#define PI 3.14159265
class Combat : public Scene {
public:
@ -24,8 +29,7 @@ class Combat : public Scene {
void draw(sf::RenderWindow *window) final override;
void updateEvents(sf::Event e) final override;
private:
bool playerOneTurn, ia, attacking, toEnemy, readingCompas;
int readCompas;
bool playerOneTurn, ia, attacking, toEnemy;
Actor *player, *enemy;
float time;
CombatState::combatState state;
@ -35,12 +39,13 @@ class Combat : public Scene {
sf::Shader _shader, _shaderHalo;
Score *scoreEnemy, *scorePlayer;
void initShader();
void enemyManager(sf::Event e);
void enemyManager(bool aux);
void animationTo(bool toEnemy, float deltaTime);
bool isAttack() const;
bool isPlayerOne() const;
void updateHalo();
void doMahWaves(bool p);
int aux;
};

View file

@ -13,9 +13,11 @@
#include <string>
#include "soundmanager.hpp"
const int SCENE_NUM = 4;
#define MARGEERR 0.2f
#define MARGEERR 0.25f
#define BLACKVALUE 0.4f
#define W_WIDTH 1024
#define UTC (0)
#define W_HEIGHT 768
const std::string WORK_DIR(getenv("WORK_DIR"));
@ -50,8 +52,4 @@ namespace CombatState {
enum combatState{player_def = 0, player_atk = 1, enemy_def = 2, enemy_atk = 3};
}
namespace DefenseResult {
enum defenseResult{nothing = 0, success = 1, fail = 2};
}
#endif // COMMONS_HPP

View file

@ -9,7 +9,7 @@ Compas::Compas() {
void Compas::start() {
failed = false;
if (not isPress) {
// std::cout << "start" << std::endl;
// //std::cout << "start" << std::endl;
isPress = true;
spaceTime = 1;
notes = std::vector<int>();
@ -20,16 +20,16 @@ void Compas::add() {
if (isPress) {
notes.push_back(spaceTime);
spaceTime = 1;
// std::cout << "add" << std::endl;
// //std::cout << "add" << std::endl;
}
}
void Compas::end() {
if (isPress) {
isPress = false;
// std::cout << "end" << std::endl;
// //std::cout << "end" << std::endl;
// for (int i = 0; i < notes.size(); ++i) {
// std::cout << notes[i] << std::endl;
// //std::cout << notes[i] << std::endl;
// }
}
}
@ -39,7 +39,7 @@ void Compas::fail() {
end();
}
void Compas::increaseTime() {
void Compas::incraeseTime() {
++spaceTime;
}
@ -51,17 +51,6 @@ bool Compas::isFailed() const {
return failed;
}
bool Compas::check(int note) {
std::cout << "Checking note " << note << std::endl;
bool res = false;
if(isPress) {
res = (std::abs((float) note - spaceTime) / (float) note) < (MARGEERR);
spaceTime = 1;
}
return res;
}
const std::vector<int>& Compas::getNotes() const
{
return notes;

View file

@ -12,19 +12,18 @@ private:
bool failed;
int spaceTime;
std::vector<int> notes;
int get(int i) const;
int size() const;
public:
Compas();
int get(int i) const;
int size() const;
void start();
void add();
void end();
void fail();
void increaseTime();
void incraeseTime();
bool isPressed() const;
bool isFailed() const;
bool check(int note);
bool operator ==(const Compas& d) const;
const std::vector<int> &getNotes() const;
};

View file

@ -20,15 +20,17 @@ 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();
while (isRunning) {
float time = c.getElapsedTime().asSeconds();
float deltaTime = time-oldTime;
oldTime = time;
//std::cout << deltaTime << std::endl;
////std::cout << deltaTime << std::endl;
update(deltaTime, &window);
draw( &window);
}

View file

@ -8,5 +8,3 @@ bool IaEnemy::updateLogic(float deltaTime, sf::RenderWindow *window) {
}
bool IaEnemy::event(sf::Event e) {return false;}
DefenseResult::defenseResult IaEnemy::event(sf::Event e, int note) {return DefenseResult::fail;}

View file

@ -8,7 +8,6 @@ public:
IaEnemy();
IaEnemy(int player);
bool event(sf::Event e) final override;
DefenseResult::defenseResult event(sf::Event e, int note) final override;
protected:
bool updateLogic(float deltaTime, sf::RenderWindow *window);

View file

@ -17,7 +17,7 @@ Menu::Menu() {
void Menu::update(float deltaTime, sf::RenderWindow*window){
//float dx = InputManager::action(InputAction::moveX0);
//_buttons[0]->move(dx,0);
//std::cout << dx << std::endl;
////std::cout << dx << std::endl;
for(unsigned int i = 0; i < _buttons.size(); ++i){
_buttons[i]->update(window->mapPixelToCoords(sf::Vector2i(sf::Mouse::getPosition(*window))));
}
@ -31,14 +31,14 @@ void Menu::draw(sf::RenderWindow* window){
}
void Menu::updateEvents(sf::Event e){
// std::cout << "update menu buttons" << std::endl;
// //std::cout << "update menu buttons" << std::endl;
for(unsigned int i = 0; i < _buttons.size(); ++i){
_buttons[i]->handleMouseEvent(e);
}
MyGame* g = static_cast<MyGame*>(Game::i());
if (_start.getClicks() > 0){
g->changeScene(GameScene::inGame);
std::cout << "Game not ready to be played. Please Wait." << std::endl;
//std::cout << "Game not ready to be played. Please Wait." << std::endl;
}
else if(_exit.getClicks() > 0) g->isRunning = false;

View file

@ -8,9 +8,8 @@ MyGame::MyGame() {
_scenes[GameScene::inGame] = _combat;
_scenes[GameScene::help] = _menu;
_scenes[GameScene::credits] = _menu;
std::cout << "in menu" << std::endl;
//std::cout << "in menu" << std::endl;
SoundManager::load();
SoundManager::setGlobalSoundVolumen(50);
SoundManager::setLoop(true, "intro");
SoundManager::playMusic("intro");
}
@ -31,6 +30,7 @@ void MyGame::changeScene(GameScene::gameScene n){
_combat = new Combat;
_scenes[_scene] = _combat;
SoundManager::setLoop(true, "clicks");
SoundManager::setVolume(85,"clicks");
SoundManager::playMusic("clicks");
}
}
@ -38,7 +38,7 @@ void MyGame::changeScene(GameScene::gameScene n){
// Main game loop
void MyGame::update(float deltaTime, sf::RenderWindow*window) {
// std::cout << deltaTime << std::endl;
// //std::cout << deltaTime << std::endl;
sf::Event event;
while(window->pollEvent(event)){
switch (event.type) {
@ -56,7 +56,7 @@ void MyGame::update(float deltaTime, sf::RenderWindow*window) {
switch(_scene){
case(GameScene::menu):
//std::cout << "still in menu" << std::endl;
////std::cout << "still in menu" << std::endl;
break;
default:
break;

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.increaseTime();
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,9 +31,11 @@ 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;
//std::cout << "playing sample " << sample << std::endl;
compas.start();
error = false;
}
@ -57,44 +65,3 @@ bool Player::event(sf::Event e) {
}
return true;
}
DefenseResult::defenseResult Player::event(sf::Event e, int note) {
std::cout << "Let's read an event" << std::endl;
switch(e.type) {
case (sf::Event::KeyPressed):
if(e.key.code == sf::Keyboard::C) {
std::string sample = "note"+std::to_string(rand()%4+1);
SoundManager::playSound(sample);
std::cout << "playing sample " << sample << std::endl;
if(!compas.isPressed()) compas.start();
error = false;
}
if(e.key.code == sf::Keyboard::Space) {
if (animate == PlayerState::idle && !error) {
std::cout << "Let's check notes" << std::endl;
bool correct = compas.check(note);
if(!correct) {
animate = PlayerState::hurt;
compas.end();
return DefenseResult::fail;
}
else {
animate = PlayerState::attacking;
return DefenseResult::success;
}
}
else {
if (!error) {
compas.fail();
animate = PlayerState::hurt;
error = true;
return DefenseResult::fail;
}
}
}
break;
default:
break;
}
return DefenseResult::nothing;
}

View file

@ -9,13 +9,13 @@ public:
Player();
Player(int num);
bool event(sf::Event e) final override;
DefenseResult::defenseResult event(sf::Event e, int note) final override;
protected:
bool updateLogic(float deltaTime, sf::RenderWindow *window);
private:
float time;
bool error;
bool mod;
float clock = 0.0;
};
#endif // PLAYER_H

Some files were not shown because too many files have changed in this diff Show more