Animations are now being pulled correctly but I need to add a timing concept to animations instead of ticks.
This commit is contained in:
parent
517de91a5b
commit
c33f370572
10 changed files with 43 additions and 22 deletions
|
|
@ -1,5 +1,6 @@
|
|||
#include "boss/fight.hpp"
|
||||
#include "boss/system.hpp"
|
||||
#include "animation.hpp"
|
||||
|
||||
namespace boss {
|
||||
Fight::Fight(shared_ptr<World> world, Entity boss_id) :
|
||||
|
|
@ -87,6 +88,9 @@ namespace boss {
|
|||
boss::System::combat(attack_id);
|
||||
state(State::PLAYER_TURN);
|
||||
} break;
|
||||
case TICK:
|
||||
$ui.play_animations();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
// skip it
|
||||
|
|
@ -104,10 +108,14 @@ namespace boss {
|
|||
case ATTACK: {
|
||||
$ui.status(L"BOSS TURN");
|
||||
$ui.move_boss(run % 10 < 5 ? "boss1" : "boss3");
|
||||
$ui.$boss_anim.play();
|
||||
int attack_id = std::any_cast<int>(data);
|
||||
boss::System::combat(attack_id);
|
||||
state(State::BOSS_TURN);
|
||||
} break;
|
||||
case TICK:
|
||||
$ui.play_animations();
|
||||
break;
|
||||
default:
|
||||
// skip it
|
||||
break;
|
||||
|
|
|
|||
15
boss/ui.cpp
15
boss/ui.cpp
|
|
@ -1,6 +1,7 @@
|
|||
#include "boss/ui.hpp"
|
||||
#include "constants.hpp"
|
||||
#include "components.hpp"
|
||||
#include "animation.hpp"
|
||||
|
||||
namespace boss {
|
||||
using namespace guecs;
|
||||
|
|
@ -18,6 +19,9 @@ namespace boss {
|
|||
$floor_sprite = textures::get_sprite(*$scene.floor);
|
||||
|
||||
$player_sprite = textures::get_sprite($scene.player["sprite"]);
|
||||
|
||||
dbc::check(animation::has(sprite.name), "add boss animation to animations.json");
|
||||
$boss_anim = animation::load(sprite.name);
|
||||
}
|
||||
|
||||
void UI::init() {
|
||||
|
|
@ -92,12 +96,19 @@ namespace boss {
|
|||
}
|
||||
|
||||
void UI::move_boss(const std::string& cell_name) {
|
||||
dbc::log(cell_name);
|
||||
position_sprite($boss_sprite, cell_name, $scene.boss["scale"], $scene.boss["mid_cell"]);
|
||||
|
||||
auto& cell = $arena.cell_for(cell_name);
|
||||
$boss_pos = {float(cell.mid_x), float(cell.mid_y)};
|
||||
}
|
||||
|
||||
void UI::move_player(const std::string& cell_name) {
|
||||
dbc::log(cell_name);
|
||||
position_sprite($player_sprite, cell_name, $scene.player["scale"], $scene.player["mid_cell"]);
|
||||
}
|
||||
|
||||
void UI::play_animations() {
|
||||
if($boss_anim.playing) {
|
||||
animation::apply($boss_anim, *$boss_sprite.sprite, $boss_pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,10 +5,7 @@
|
|||
#include <guecs/ui.hpp>
|
||||
#include "textures.hpp"
|
||||
#include "gui/combat_ui.hpp"
|
||||
|
||||
namespace components {
|
||||
struct BossFight;
|
||||
}
|
||||
#include "components.hpp"
|
||||
|
||||
namespace boss {
|
||||
using std::shared_ptr;
|
||||
|
|
@ -25,6 +22,8 @@ namespace boss {
|
|||
SpriteTexture $floor_sprite;
|
||||
guecs::UI $arena;
|
||||
guecs::UI $actions;
|
||||
components::Animation $boss_anim;
|
||||
sf::Vector2f $boss_pos;
|
||||
|
||||
UI(shared_ptr<World> world, Entity boss_id);
|
||||
|
||||
|
|
@ -35,5 +34,6 @@ namespace boss {
|
|||
void status(const std::wstring& msg);
|
||||
void move_boss(const std::string& cell_name);
|
||||
void move_player(const std::string& cell_name);
|
||||
void play_animations();
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue