merge?
This commit is contained in:
parent
bfa92e8b43
commit
3b3aca7549
1 changed files with 14 additions and 6 deletions
|
@ -7,7 +7,11 @@ Combat::Combat() {
|
||||||
player = new Player(0);
|
player = new Player(0);
|
||||||
// enemy = new IaEnemy(1);
|
// enemy = new IaEnemy(1);
|
||||||
enemy = new Player(1);
|
enemy = new Player(1);
|
||||||
|
scorePlayer = new Score(0);
|
||||||
|
scoreEnemy = new Score(1);
|
||||||
initShader();
|
initShader();
|
||||||
|
|
||||||
|
SoundManager::load();
|
||||||
SoundManager::playMusic("music");
|
SoundManager::playMusic("music");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,6 +44,8 @@ void Combat::draw(sf::RenderWindow *window) {
|
||||||
window->draw(_background, &_shader);
|
window->draw(_background, &_shader);
|
||||||
player->draw(window);
|
player->draw(window);
|
||||||
enemy->draw(window);
|
enemy->draw(window);
|
||||||
|
window->draw(*scorePlayer);
|
||||||
|
window->draw(*scoreEnemy);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Combat::updateEvents(sf::Event e) {
|
void Combat::updateEvents(sf::Event e) {
|
||||||
|
@ -47,9 +53,10 @@ void Combat::updateEvents(sf::Event e) {
|
||||||
bool aux = player->event(e);
|
bool aux = player->event(e);
|
||||||
if (!aux) { //end of player one ritm
|
if (!aux) { //end of player one ritm
|
||||||
if (!attacking) {
|
if (!attacking) {
|
||||||
if(!player->hitBy(enemy->getAttack())) enemy->upScore();
|
if(!player->hitBy(enemy->getAttack())) {
|
||||||
std::cout << "player1: " << player->getScore() << std::endl;
|
enemy->upScore();
|
||||||
std::cout << "player2: " << enemy->getScore() << std::endl;
|
scoreEnemy->setScore(enemy->getScore());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else playerOneTurn = aux;
|
else playerOneTurn = aux;
|
||||||
attacking = !attacking;
|
attacking = !attacking;
|
||||||
|
@ -64,9 +71,10 @@ void Combat::updateEvents(sf::Event e) {
|
||||||
void Combat::enemyManager(bool aux) {
|
void Combat::enemyManager(bool aux) {
|
||||||
if (aux) {
|
if (aux) {
|
||||||
if (!attacking) {
|
if (!attacking) {
|
||||||
if(!enemy->hitBy(player->getAttack())) player->upScore();
|
if(!enemy->hitBy(player->getAttack())) {
|
||||||
std::cout << "player1: " << player->getScore() << std::endl;
|
player->upScore();
|
||||||
std::cout << "player2: " << enemy->getScore() << std::endl;
|
scorePlayer->setScore(player->getScore());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else playerOneTurn = aux;
|
else playerOneTurn = aux;
|
||||||
attacking = !attacking;
|
attacking = !attacking;
|
||||||
|
|
Reference in a new issue