Now have animated torches that are defined from json, and smoother animations in the arena.
This commit is contained in:
parent
387d1a5bf5
commit
7c11ffa2af
10 changed files with 111 additions and 73 deletions
34
boss/ui.cpp
34
boss/ui.cpp
|
|
@ -35,10 +35,14 @@ namespace boss {
|
|||
auto st = textures::get_sprite(name);
|
||||
// clone the sprite so it can be positioned
|
||||
st.sprite = std::make_shared<sf::Sprite>(*st.texture);
|
||||
|
||||
auto anim = animation::load(name);
|
||||
float scale_x = fixture["scale_x"];
|
||||
float scale_y = fixture["scale_y"];
|
||||
|
||||
auto anim = animation::load(name);
|
||||
anim.scale_x = scale_x;
|
||||
anim.scale_y = scale_y;
|
||||
anim.play();
|
||||
|
||||
std::string cell = fixture["cell"];
|
||||
float x = fixture["x"];
|
||||
float y = fixture["y"];
|
||||
|
|
@ -72,6 +76,7 @@ namespace boss {
|
|||
for(auto& fixture : $fixtures) {
|
||||
position_sprite(fixture.st, fixture.cell,
|
||||
fixture.scale_x, fixture.scale_y, false, fixture.x, fixture.y);
|
||||
fixture.pos = fixture.st.sprite->getPosition();
|
||||
}
|
||||
|
||||
$arena.init();
|
||||
|
|
@ -147,27 +152,14 @@ namespace boss {
|
|||
position_sprite($player_sprite, cell_name, scale, scale, $scene.player["mid_cell"]);
|
||||
}
|
||||
|
||||
void UI::play_animations(sf::RenderWindow& window) {
|
||||
if($boss_anim.playing) {
|
||||
using namespace std::chrono_literals;
|
||||
auto& sound = $world->get<components::Sound>($boss_id);
|
||||
|
||||
animation::apply($boss_anim, *$boss_sprite.sprite, $boss_pos);
|
||||
|
||||
if($boss_anim.current == 1 && !sound::playing(sound.attack)) {
|
||||
sound::play(sound.attack);
|
||||
void UI::play_animations() {
|
||||
for(auto& fixture : $fixtures) {
|
||||
if(fixture.anim.playing) {
|
||||
animation::apply(fixture.anim, *fixture.st.sprite, fixture.pos);
|
||||
}
|
||||
}
|
||||
|
||||
// https://www.construct.net/en/blogs/ashleys-blog-2/using-lerp-delta-time-924
|
||||
|
||||
// frame start
|
||||
render(window);
|
||||
window.display();
|
||||
// frame end
|
||||
// deltaTime = end - start
|
||||
// lerp(a, b, 1 - f ^ deltaTime)
|
||||
// std::this_thread::sleep_for(16ms);
|
||||
} else {
|
||||
if($boss_anim.playing) {
|
||||
animation::apply($boss_anim, *$boss_sprite.sprite, $boss_pos);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue