Can now pan and move the camera to focus on bosses, player, and their actions.
This commit is contained in:
parent
51bb74e2d7
commit
22db12f5e4
6 changed files with 38 additions and 28 deletions
29
scene.cpp
29
scene.cpp
|
|
@ -36,8 +36,6 @@ namespace scene {
|
|||
Engine::Engine(components::AnimatedScene& scene) :
|
||||
$scene(scene)
|
||||
{
|
||||
$camera.style("dolly");
|
||||
|
||||
for(auto& config : $scene.actors) {
|
||||
auto element = config_scene_element(config, false, false);
|
||||
dbc::check(!$actor_name_ids.contains(element.name),
|
||||
|
|
@ -167,16 +165,35 @@ namespace scene {
|
|||
$camera.play();
|
||||
}
|
||||
|
||||
std::pair<Element&, Element&> Engine::left_right(const std::string &actor, const std::string &target) {
|
||||
auto& first = actor_config(actor);
|
||||
auto& second = actor_config(target);
|
||||
|
||||
if(first.pos.x < second.pos.x) {
|
||||
// first is left
|
||||
return {first, second};
|
||||
} else if(first.pos.x == second.pos.x) {
|
||||
auto fb = first.st.sprite->getGlobalBounds();
|
||||
auto sb = second.st.sprite->getGlobalBounds();
|
||||
|
||||
// use the widest one as right
|
||||
if(fb.size.x >= sb.size.x) {
|
||||
return {first, second};
|
||||
} else {
|
||||
return {second, first};
|
||||
}
|
||||
} else {
|
||||
// second is left
|
||||
return {second, first};
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue