Skip to content

Commit

Permalink
para bailar esto es una bomba
Browse files Browse the repository at this point in the history
  • Loading branch information
enano4k committed Apr 19, 2020
1 parent a90ea2a commit 4a04e25
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 30 deletions.
3 changes: 3 additions & 0 deletions include/Character/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<ShadowControl*> shadows;
Expand All @@ -136,6 +137,8 @@ class Player : public Character
void exit();
bool isOnIntro();
void activateBomb();
void disableBomb();
void bombLogic();
};

#endif
3 changes: 2 additions & 1 deletion src/Character/Character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
}
79 changes: 50 additions & 29 deletions src/Character/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,18 @@ Player::Player(std::string name, int sound_channel_base, vector<string> 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()
Expand Down Expand Up @@ -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++;
Expand Down Expand Up @@ -748,25 +755,11 @@ void Player::topRender()
parry_hitboxes[i]->getAngle(), 100, 0, 0, 100);
}

/*
std::vector<Image *> 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;
}
}
}

Expand Down Expand Up @@ -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;
}
}
}

0 comments on commit 4a04e25

Please sign in to comment.