diff --git a/boss/fight.cpp b/boss/fight.cpp index 502fc18..c92c334 100644 --- a/boss/fight.cpp +++ b/boss/fight.cpp @@ -84,7 +84,9 @@ namespace boss { break; case ATTACK: { $ui.status(L"PLAYER TURN"); - $ui.move_actor("player", run % 10 < 5 ? "player1" : "player2"); + const std::string& player_pos = run % 10 < 5 ? "player1" : "player2"; + $ui.move_actor("player", player_pos); + $ui.zoom(player_pos); int attack_id = std::any_cast(data); boss::System::combat(attack_id); state(State::PLAYER_TURN); @@ -105,7 +107,9 @@ namespace boss { break; case ATTACK: { $ui.status(L"BOSS TURN"); - $ui.move_actor("boss", run % 10 < 5 ? "boss5" : "boss6"); + const std::string &boss_at = run % 10 < 5 ? "boss5" : "boss6"; + $ui.move_actor("boss", boss_at); + $ui.zoom(""); $ui.animate_actor("boss"); int attack_id = std::any_cast(data); boss::System::combat(attack_id); diff --git a/boss/ui.cpp b/boss/ui.cpp index 5f81ed8..cc97599 100644 --- a/boss/ui.cpp +++ b/boss/ui.cpp @@ -66,4 +66,18 @@ namespace boss { void UI::play_animations() { $arena.play_animations(); } + + void UI::zoom(const std::string &cell_name) { + 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 { + 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}}; + $view_texture.setView(zoom); + } + + $view_sprite.setPosition({BOSS_VIEW_X, BOSS_VIEW_Y}); + } } diff --git a/boss/ui.hpp b/boss/ui.hpp index b81515f..1ff4994 100644 --- a/boss/ui.hpp +++ b/boss/ui.hpp @@ -24,5 +24,6 @@ namespace boss { void move_actor(const std::string& actor, const std::string& cell_name); void animate_actor(const std::string& actor); void play_animations(); + void zoom(const std::string &cell); }; }