BAD: This gets the animation to control the camera, but it's a quick hack to prove it works.
This commit is contained in:
parent
cb58bdd955
commit
102c8c36d5
5 changed files with 63 additions and 18 deletions
|
|
@ -86,7 +86,7 @@ namespace boss {
|
|||
$ui.status(L"PLAYER TURN");
|
||||
const std::string& player_pos = run % 10 < 5 ? "player1" : "player2";
|
||||
$ui.move_actor("player", player_pos);
|
||||
$ui.zoom(player_pos);
|
||||
$ui.$zoom_anim.play();
|
||||
int attack_id = std::any_cast<int>(data);
|
||||
boss::System::combat(attack_id);
|
||||
state(State::PLAYER_TURN);
|
||||
|
|
|
|||
31
boss/ui.cpp
31
boss/ui.cpp
|
|
@ -1,6 +1,8 @@
|
|||
#include "boss/ui.hpp"
|
||||
#include "scene.hpp"
|
||||
#include "constants.hpp"
|
||||
#include "components.hpp"
|
||||
#include "animation.hpp"
|
||||
|
||||
namespace boss {
|
||||
using namespace guecs;
|
||||
|
|
@ -10,7 +12,8 @@ namespace boss {
|
|||
$combat_ui(true),
|
||||
$arena(scene),
|
||||
$view_texture({BOSS_VIEW_WIDTH, BOSS_VIEW_HEIGHT}),
|
||||
$view_sprite($view_texture.getTexture())
|
||||
$view_sprite($view_texture.getTexture()),
|
||||
$zoom_anim(animation::load("test_zoom"))
|
||||
{
|
||||
$view_sprite.setPosition({BOSS_VIEW_X, BOSS_VIEW_Y});
|
||||
}
|
||||
|
|
@ -40,6 +43,11 @@ namespace boss {
|
|||
void UI::render(sf::RenderWindow& window) {
|
||||
$actions.render(window);
|
||||
$combat_ui.render(window);
|
||||
|
||||
if($zoom_anim.playing) {
|
||||
zoom("player2");
|
||||
}
|
||||
|
||||
$arena.render($view_texture);
|
||||
$view_texture.display();
|
||||
window.draw($view_sprite);
|
||||
|
|
@ -71,10 +79,25 @@ namespace boss {
|
|||
if(cell_name == "") {
|
||||
sf::View zoom{{BOSS_VIEW_WIDTH/2,BOSS_VIEW_HEIGHT/2}, {BOSS_VIEW_WIDTH, BOSS_VIEW_HEIGHT}};
|
||||
$view_texture.setView(zoom);
|
||||
} else {
|
||||
} else if($zoom_anim.playing) {
|
||||
auto& cell = $arena.$ui.cell_for(cell_name);
|
||||
sf::View zoom{{(float)cell.mid_x, (float)cell.mid_y},
|
||||
{(float)cell.w*3, (float)cell.h*3}};
|
||||
sf::Vector2f scale{$zoom_anim.min_x, $zoom_anim.min_y};
|
||||
sf::Vector2f pos{float(cell.x), float(cell.y)};
|
||||
sf::IntRect rect{{0,0}, {cell.w, cell.h}};
|
||||
|
||||
$zoom_anim.step(scale, pos, rect);
|
||||
fmt::println("SCALE: {},{}; pos: {},{}; rect: {},{};{},{}",
|
||||
scale.x, scale.y, pos.x, pos.y,
|
||||
rect.position.x, rect.position.y,
|
||||
rect.size.x, rect.size.y);
|
||||
|
||||
sf::View zoom{pos,
|
||||
{float(cell.w * 2), float(cell.h * 2)}};
|
||||
|
||||
if($zoom_anim.scaled) {
|
||||
zoom.zoom(scale.x);
|
||||
}
|
||||
|
||||
$view_texture.setView(zoom);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,10 @@
|
|||
#include "gui/combat_ui.hpp"
|
||||
#include "scene.hpp"
|
||||
|
||||
namespace components {
|
||||
struct Animation;
|
||||
}
|
||||
|
||||
namespace boss {
|
||||
using std::shared_ptr;
|
||||
|
||||
|
|
@ -14,6 +18,7 @@ namespace boss {
|
|||
guecs::UI $actions;
|
||||
sf::RenderTexture $view_texture;
|
||||
sf::Sprite $view_sprite;
|
||||
components::Animation $zoom_anim;
|
||||
|
||||
UI(components::AnimatedScene &scene, DinkyECS::Entity boss_id);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue