Camera is now using animate2 but isn't actually using it yet. Just converted.
This commit is contained in:
parent
7bf7b25a10
commit
46cc21ec7b
8 changed files with 111 additions and 90 deletions
31
camera.cpp
31
camera.cpp
|
|
@ -1,16 +1,16 @@
|
|||
#include "camera.hpp"
|
||||
#include <fmt/core.h>
|
||||
#include "animation.hpp"
|
||||
#include <unordered_map>
|
||||
#include "components.hpp"
|
||||
#include "config.hpp"
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
|
||||
namespace cinematic {
|
||||
using components::Animation, std::string, std::min, std::clamp;
|
||||
using animate2::Animate2, std::string, std::min, std::clamp;
|
||||
|
||||
struct CameraManager {
|
||||
std::unordered_map<string, Animation> animations;
|
||||
std::unordered_map<string, Animate2> animations;
|
||||
};
|
||||
|
||||
static CameraManager MGR;
|
||||
|
|
@ -18,18 +18,15 @@ namespace cinematic {
|
|||
|
||||
void init() {
|
||||
if(!initialized) {
|
||||
auto cameras = settings::get("cameras");
|
||||
for(auto &[name, data] : cameras.json().items()) {
|
||||
auto anim = components::convert<Animation>(data);
|
||||
MGR.animations.try_emplace(name, anim);
|
||||
}
|
||||
|
||||
auto data = settings::get("cameras");
|
||||
auto anim = components::convert<Animate2>(data["cameras"]);
|
||||
MGR.animations.try_emplace("main", anim);
|
||||
initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
Camera::Camera(sf::Vector2f size) :
|
||||
anim(MGR.animations.at("pan")),
|
||||
anim(MGR.animations.at("main")),
|
||||
size(size),
|
||||
base_size(size),
|
||||
aimed_at{size.x/2, size.y/2},
|
||||
|
|
@ -63,7 +60,7 @@ namespace cinematic {
|
|||
}
|
||||
|
||||
void Camera::style(const std::string &name) {
|
||||
anim = MGR.animations.at(name);
|
||||
anim.set_form(name);
|
||||
}
|
||||
|
||||
void Camera::position(float x, float y) {
|
||||
|
|
@ -76,12 +73,12 @@ namespace cinematic {
|
|||
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.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;
|
||||
//}
|
||||
}
|
||||
|
||||
void Camera::reset(sf::RenderTexture& target) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue