Better working camera that is constrained in the bounds, but the animations don't follow the bounding.

This commit is contained in:
Zed A. Shaw 2026-01-01 12:59:39 -05:00
parent 6dc9d564c6
commit 51bb74e2d7
9 changed files with 93 additions and 33 deletions

View file

@ -36,7 +36,7 @@ namespace scene {
Engine::Engine(components::AnimatedScene& scene) :
$scene(scene)
{
$camera.style("shake");
$camera.style("dolly");
for(auto& config : $scene.actors) {
auto element = config_scene_element(config, false, false);
@ -161,17 +161,26 @@ namespace scene {
return pos;
}
void Engine::zoom(int mid_x, int mid_y, int width, int height) {
$camera.resize(float(width), float(height));
$camera.move(float(mid_x), float(mid_y));
void Engine::zoom(float mid_x, float mid_y, float scale) {
$camera.scale(scale);
$camera.move(mid_x, mid_y);
$camera.play();
}
void Engine::zoom(const std::string &cell_name) {
auto& cell = $ui.cell_for(cell_name);
zoom(cell.w, cell.h, cell.mid_x, cell.mid_y);
void Engine::zoom(const std::string &actor, float scale) {
auto& config = actor_config(actor);
auto bounds = config.st.sprite->getGlobalBounds();
float mid_x = config.pos.x + bounds.size.x / 2.0f;
float mid_y = config.pos.y + bounds.size.y / 2.0f;
fmt::println("CAMERA in scene::Engine I'm zooming {} by {} @ {},{} size {},{}; going_to mid={},{}",
actor, scale, config.pos.x, config.pos.y,
bounds.size.x, bounds.size.y, mid_x, mid_y);
zoom(mid_x, mid_y, scale);
}
void Engine::reset(sf::RenderTexture& view, float width, float height) {
$camera.reset(view, width, height);
void Engine::reset(sf::RenderTexture& view) {
$camera.reset(view);
}
}