New boss scene that's really just a pixelated photo bash done quickly.
This commit is contained in:
parent
ca38b58450
commit
7f10c5b3d7
10 changed files with 37 additions and 29 deletions
|
|
@ -105,7 +105,7 @@ namespace boss {
|
|||
break;
|
||||
case ATTACK: {
|
||||
$ui.status(L"BOSS TURN");
|
||||
$ui.move_boss(run % 10 < 5 ? "boss1" : "boss2");
|
||||
$ui.move_boss(run % 10 < 5 ? "boss5" : "boss6");
|
||||
$ui.$boss_anim.play();
|
||||
int attack_id = std::any_cast<int>(data);
|
||||
boss::System::combat(attack_id);
|
||||
|
|
@ -128,7 +128,7 @@ namespace boss {
|
|||
}
|
||||
|
||||
void Fight::render(sf::RenderWindow& window) {
|
||||
$ui.render(window);
|
||||
$ui.play_animations(window);
|
||||
$ui.render(window);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
20
boss/ui.cpp
20
boss/ui.cpp
|
|
@ -31,7 +31,7 @@ namespace boss {
|
|||
|
||||
void UI::init() {
|
||||
$arena.position(SCREEN_WIDTH-BOSS_VIEW_WIDTH,0, BOSS_VIEW_WIDTH, SCREEN_HEIGHT);
|
||||
$arena.set<Background>($arena.MAIN, {$arena.$parser, THEME.DARK_MID});
|
||||
$arena.set<Background>($arena.MAIN, {$arena.$parser, THEME.TRANSPARENT});
|
||||
auto& background = $arena.get<Background>($arena.MAIN);
|
||||
background.set_sprite($scene.background, true);
|
||||
|
||||
|
|
@ -82,14 +82,16 @@ namespace boss {
|
|||
}
|
||||
|
||||
void UI::render(sf::RenderWindow& window) {
|
||||
|
||||
$actions.render(window);
|
||||
$combat_ui.render(window);
|
||||
$arena.render(window);
|
||||
|
||||
if($floor_sprite.sprite) {
|
||||
window.draw(*$floor_sprite.sprite);
|
||||
}
|
||||
|
||||
$arena.render(window);
|
||||
|
||||
window.draw(*$boss_sprite.sprite);
|
||||
window.draw(*$player_sprite.sprite);
|
||||
|
||||
|
|
@ -118,19 +120,25 @@ namespace boss {
|
|||
}
|
||||
|
||||
void UI::play_animations(sf::RenderWindow& window) {
|
||||
using namespace std::chrono_literals;
|
||||
auto& sound = $world->get<components::Sound>($boss_id);
|
||||
if($boss_anim.playing) {
|
||||
using namespace std::chrono_literals;
|
||||
auto& sound = $world->get<components::Sound>($boss_id);
|
||||
|
||||
while($boss_anim.playing) {
|
||||
animation::apply($boss_anim, *$boss_sprite.sprite, $boss_pos);
|
||||
|
||||
if($boss_anim.current == 1 && !sound::playing(sound.attack)) {
|
||||
sound::play(sound.attack);
|
||||
}
|
||||
|
||||
// https://www.construct.net/en/blogs/ashleys-blog-2/using-lerp-delta-time-924
|
||||
|
||||
// frame start
|
||||
render(window);
|
||||
window.display();
|
||||
std::this_thread::sleep_for(16ms);
|
||||
// frame end
|
||||
// deltaTime = end - start
|
||||
// lerp(a, b, 1 - f ^ deltaTime)
|
||||
// std::this_thread::sleep_for(16ms);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue