Bosses and other enemies now have a 2 frame animation, the first boss the Rat King now screams at you and attacks.
This commit is contained in:
parent
b3b8cbbeee
commit
43835da88f
24 changed files with 35 additions and 22 deletions
|
@ -24,7 +24,10 @@ namespace gui {
|
|||
auto bg_bounds = $boss_background.sprite->getLocalBounds();
|
||||
$boss_background.sprite->setPosition({300, 0});
|
||||
|
||||
$boss_image = textures::get("boss_fight");
|
||||
$boss_image = textures::get("rat_king_boss");
|
||||
sf::IntRect frame_rect{{0,0},{720,720}};
|
||||
$boss_image.sprite->setTextureRect(frame_rect);
|
||||
$boss_image.sprite->setScale($scale);
|
||||
auto bounds = $boss_image.sprite->getLocalBounds();
|
||||
float x_diff = bg_bounds.size.x / 2;
|
||||
$boss_image.sprite->setOrigin({bounds.size.x / 2, bounds.size.y / 2});
|
||||
|
@ -34,6 +37,8 @@ namespace gui {
|
|||
void BossFightUI::init() {
|
||||
auto& config = $level.world->get_the<components::GameConfig>();
|
||||
$sounds = components::get<components::Sound>(config.enemies["RAT_KING"]);
|
||||
$animation = components::get<components::Animation>(config.enemies["RAT_KING"]);
|
||||
$animation.texture_width = 720;
|
||||
|
||||
$status.world().set_the<Background>({$status.$parser});
|
||||
|
||||
|
@ -62,16 +67,20 @@ namespace gui {
|
|||
}
|
||||
|
||||
void BossFightUI::bounce_boss(sf::RenderWindow& window) {
|
||||
auto time = $clock.getElapsedTime();
|
||||
float tick = ease::in_out_back(ease::sine(time.asSeconds() * 10.0f));
|
||||
float scale = std::lerp(0.8, 1.1, tick);
|
||||
$boss_image.sprite->setScale({scale, scale});
|
||||
sf::IntRect frame_rect{{0,0},{720,720}};
|
||||
auto scale = $scale;
|
||||
$animation.step(scale, frame_rect);
|
||||
$boss_image.sprite->setScale(scale);
|
||||
|
||||
if(scale > 1.0) {
|
||||
if(!sound::playing($sounds.attack)) sound::play($sounds.attack);
|
||||
$boss_image.sprite->setColor({255,255,255});
|
||||
if(!sound::playing($sounds.attack) && $animation.current == 1) {
|
||||
sound::play($sounds.attack);
|
||||
}
|
||||
|
||||
if(!sound::playing("Sword_Hit_2") && $animation.subframe > 1.2 && $animation.subframe < 1.5) {
|
||||
sound::play("Sword_Hit_2");
|
||||
}
|
||||
|
||||
$boss_image.sprite->setTextureRect(frame_rect);
|
||||
window.draw(*$boss_image.sprite);
|
||||
}
|
||||
|
||||
|
@ -99,8 +108,8 @@ namespace gui {
|
|||
}
|
||||
|
||||
if($overlay.mouse(x, y)) {
|
||||
$animation.play();
|
||||
sound::play("Sword_Hit_1");
|
||||
$boss_image.sprite->setColor({255,225,225});
|
||||
$boss_hit = !$boss_hit;
|
||||
$boss_hp--;
|
||||
}
|
||||
|
@ -109,7 +118,6 @@ namespace gui {
|
|||
}
|
||||
|
||||
void BossFightUI::update_level(GameLevel &level) {
|
||||
$boss_image.sprite->setColor({255,255,255});
|
||||
$level = level;
|
||||
$boss_hp = 10 * $level.index + 1; // make him stronger
|
||||
$boss_hit = false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue