Animations can now be applied to sf::View to do animated camera effects.

This commit is contained in:
Zed A. Shaw 2025-11-01 12:29:22 -04:00
parent d60e1af6df
commit f1f4cbc80f
4 changed files with 27 additions and 22 deletions

View file

@ -81,23 +81,9 @@ namespace boss {
$view_texture.setView(zoom);
} else if($zoom_anim.playing) {
auto& cell = $arena.$ui.cell_for(cell_name);
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,
{BOSS_VIEW_WIDTH/2, BOSS_VIEW_HEIGHT/2}};
if($zoom_anim.scaled) {
zoom.zoom(scale.x);
}
sf::View zoom;
$zoom_anim.apply(zoom, pos, {BOSS_VIEW_WIDTH/2, BOSS_VIEW_HEIGHT/2});
$view_texture.setView(zoom);
}