Camera is now using Animate2 and it's mostly working, but there's a few more refactors needed.

This commit is contained in:
Zed A. Shaw 2026-02-20 00:15:19 -05:00
parent 46cc21ec7b
commit 364f66bffb
14 changed files with 106 additions and 62 deletions

View file

@ -1,5 +1,4 @@
#include "camera.hpp"
#include <fmt/core.h>
#include <unordered_map>
#include "components.hpp"
#include "config.hpp"
@ -72,13 +71,12 @@ namespace cinematic {
going_to.x = clamp(x, camera_bounds.position.x, camera_bounds.size.x);
going_to.y = clamp(y, camera_bounds.position.y, camera_bounds.size.y);
// BUG: annoying special case
//if(anim.motion == ease::SLIDE) {
// anim.min_x = aimed_at.x;
// anim.min_y = aimed_at.y;
// anim.max_x = going_to.x;
// anim.max_y = going_to.y;
//}
if(!anim.transform.relative) {
anim.transform.min_x = aimed_at.x;
anim.transform.min_y = aimed_at.y;
anim.transform.max_x = going_to.x;
anim.transform.max_y = going_to.y;
}
}
void Camera::reset(sf::RenderTexture& target) {
@ -94,11 +92,17 @@ namespace cinematic {
void Camera::render(sf::RenderTexture& target) {
if(anim.playing) {
anim.apply(view, going_to, size);
anim.motion(view, going_to, size);
target.setView(view);
}
}
void Camera::update() {
// REFACTOR: there's no connection between anim.commit() and anim.update()
auto [ticks, alpha] = anim.commit();
if(anim.playing) anim.update();
}
bool Camera::playing() {
return anim.playing;
}