From 4a04e25d20f6dbcb2aa6b688c5f08a97440786fc Mon Sep 17 00:00:00 2001 From: enano4k Date: Sat, 18 Apr 2020 18:20:56 -0600 Subject: [PATCH] para bailar esto es una bomba --- include/Character/Player.h | 3 ++ src/Character/Character.cpp | 3 +- src/Character/Player.cpp | 79 +++++++++++++++++++++++-------------- 3 files changed, 55 insertions(+), 30 deletions(-) diff --git a/include/Character/Player.h b/include/Character/Player.h index be0b12b..1d47b93 100644 --- a/include/Character/Player.h +++ b/include/Character/Player.h @@ -114,6 +114,7 @@ class Player : public Character int current_bomb_image; int bomb_image_duration; bool is_bomb_animation_active; + bool is_bomb_active; // Shadow std::list shadows; @@ -136,6 +137,8 @@ class Player : public Character void exit(); bool isOnIntro(); void activateBomb(); + void disableBomb(); + void bombLogic(); }; #endif diff --git a/src/Character/Character.cpp b/src/Character/Character.cpp index d47ada3..14fda32 100644 --- a/src/Character/Character.cpp +++ b/src/Character/Character.cpp @@ -1011,7 +1011,8 @@ void Character::deleteActivePatterns() while (i != active_patterns->end()) { Pattern *p = (Pattern *)*i; - p->hit(sound_channel_base + 1, true); + if(!p->is_hit) + p->hit(sound_channel_base + 1, true); i++; } } diff --git a/src/Character/Player.cpp b/src/Character/Player.cpp index c44188d..8c32cd6 100644 --- a/src/Character/Player.cpp +++ b/src/Character/Player.cpp @@ -90,17 +90,18 @@ Player::Player(std::string name, int sound_channel_base, vector intro_in this->additional_hp_change = 0; this->velocity_override = 0; - // Bomb animation - bomb_images.push_back(rosalila()->graphics->getImage(std::string(assets_directory) + directory + "sprites/bomb_background/01.png")); - bomb_images.push_back(rosalila()->graphics->getImage(std::string(assets_directory) + directory + "sprites/bomb_background/02.png")); - bomb_images.push_back(rosalila()->graphics->getImage(std::string(assets_directory) + directory + "sprites/bomb_background/03.png")); - bomb_images[0]->color_filter.alpha = 255; - bomb_images[1]->color_filter.alpha = 255; - bomb_images[2]->color_filter.alpha = 255; - current_bomb_frame = 0; - current_bomb_image = 0; - bomb_image_duration = 5; - is_bomb_animation_active = false; + // Bomb + this->bomb_images.push_back(rosalila()->graphics->getImage(std::string(assets_directory) + directory + "sprites/bomb_background/01.png")); + this->bomb_images.push_back(rosalila()->graphics->getImage(std::string(assets_directory) + directory + "sprites/bomb_background/02.png")); + this->bomb_images.push_back(rosalila()->graphics->getImage(std::string(assets_directory) + directory + "sprites/bomb_background/03.png")); + this->bomb_images[0]->color_filter.alpha = 255; + this->bomb_images[1]->color_filter.alpha = 255; + this->bomb_images[2]->color_filter.alpha = 255; + this->current_bomb_frame = 0; + this->current_bomb_image = 0; + this->bomb_image_duration = 5; + this->is_bomb_animation_active = false; + this->is_bomb_active = false; } Player::~Player() @@ -570,9 +571,15 @@ void Player::logic(int stage_velocity) if (!slow_in_cooldown && current_slow <= 0) { slow_in_cooldown = true; + } + + if(!slow_in_cooldown && isDownWrapper("e")) + { this->activateBomb(); } + bombLogic(); + spellControl(stage_velocity); iteration++; @@ -748,25 +755,11 @@ void Player::topRender() parry_hitboxes[i]->getAngle(), 100, 0, 0, 100); } - /* - std::vector bomb_images; - int current_bomb_image; - int bomb_image_duration; - bool is_bomb_animation_active; - */ - if(is_bomb_animation_active) { rosalila()->graphics->drawImage(bomb_images[current_bomb_image], 0, 0); - current_bomb_frame++; - if(current_bomb_frame % bomb_image_duration == 0) - { - current_bomb_image++; - if(current_bomb_image>bomb_images.size()) - is_bomb_animation_active = false; - } } } @@ -1016,8 +1009,36 @@ bool Player::isOnIntro() void Player::activateBomb() { - current_bomb_image = 0; - current_bomb_frame = 0; - is_bomb_animation_active = true; - enemy->deleteActivePatterns(); + this->current_bomb_image = 0; + this->current_bomb_frame = 0; + this->is_bomb_animation_active = true; + this->is_bomb_active = true; +} + +void Player::disableBomb() +{ + this->is_bomb_animation_active = false; + this->is_bomb_active = false; +} + +void Player::bombLogic() +{ + if(this->is_bomb_active) + { + this->enemy->deleteActivePatterns(); + + this->current_slow-=6; + if(current_slow <= 0) + { + disableBomb(); + } + + current_bomb_frame++; + if(current_bomb_frame % bomb_image_duration == 0) + { + current_bomb_image++; + if(current_bomb_image > bomb_images.size()) + current_bomb_image = 0; + } + } } \ No newline at end of file