Moved the camera into the scene where it belongs.
This commit is contained in:
parent
c71566048e
commit
5676382fbb
5 changed files with 29 additions and 27 deletions
29
scene.cpp
29
scene.cpp
|
|
@ -34,6 +34,8 @@ namespace scene {
|
|||
Engine::Engine(components::AnimatedScene& scene) :
|
||||
$scene(scene)
|
||||
{
|
||||
$camera.style("shake");
|
||||
|
||||
for(auto& config : $scene.actors) {
|
||||
auto element = config_scene_element(config, false, false);
|
||||
dbc::check(!$actor_name_ids.contains(element.name),
|
||||
|
|
@ -90,19 +92,20 @@ namespace scene {
|
|||
return $ui.mouse(x, y, mods);
|
||||
}
|
||||
|
||||
void Engine::render(sf::RenderTarget& window) {
|
||||
$ui.render(window);
|
||||
void Engine::render(sf::RenderTexture& view) {
|
||||
$ui.render(view);
|
||||
|
||||
for(auto& fixture : $fixtures) {
|
||||
window.draw(*fixture.st.sprite, fixture.effect.get());
|
||||
view.draw(*fixture.st.sprite, fixture.effect.get());
|
||||
}
|
||||
|
||||
for(auto& actor : $actors) {
|
||||
window.draw(*actor.st.sprite, actor.effect.get());
|
||||
if(actor.anim.playing) window.draw(actor.text);
|
||||
view.draw(*actor.st.sprite, actor.effect.get());
|
||||
if(actor.anim.playing) view.draw(actor.text);
|
||||
}
|
||||
|
||||
if(DEBUG) $ui.debug_layout(window);
|
||||
$camera.render(view);
|
||||
if(DEBUG) $ui.debug_layout(view);
|
||||
}
|
||||
|
||||
Element& Engine::actor_config(const std::string& actor) {
|
||||
|
|
@ -154,4 +157,18 @@ 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(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::reset(sf::RenderTexture& view, float width, float height) {
|
||||
$camera.reset(view, width, height);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue