Now can zoom in on the player when it's their turn.

This commit is contained in:
Zed A. Shaw 2025-10-31 14:06:40 -04:00
parent 740e1052fe
commit cb58bdd955
3 changed files with 21 additions and 2 deletions

View file

@ -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<int>(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<int>(data);
boss::System::combat(attack_id);

View file

@ -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});
}
}

View file

@ -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);
};
}