Camera for the storyboard can now do pan, bounce, dolly, and shake.
This commit is contained in:
parent
0d326089f7
commit
29409c54ce
5 changed files with 23 additions and 15 deletions
|
|
@ -39,7 +39,7 @@
|
||||||
"_type": "Animation",
|
"_type": "Animation",
|
||||||
"easing": 1,
|
"easing": 1,
|
||||||
"motion": 0,
|
"motion": 0,
|
||||||
"ease_rate": 0.5,
|
"ease_rate": 1.0,
|
||||||
"min_x": 0.8,
|
"min_x": 0.8,
|
||||||
"min_y": 0.8,
|
"min_y": 0.8,
|
||||||
"max_x": 1.0,
|
"max_x": 1.0,
|
||||||
|
|
@ -55,13 +55,13 @@
|
||||||
},
|
},
|
||||||
"bounce": {
|
"bounce": {
|
||||||
"_type": "Animation",
|
"_type": "Animation",
|
||||||
"easing": 3,
|
"easing": 4,
|
||||||
"motion": 2,
|
"motion": 2,
|
||||||
"ease_rate": 0.05,
|
"ease_rate": 0.001,
|
||||||
"min_x": -10,
|
"min_x": 0,
|
||||||
"min_y": -10,
|
"min_y": -20,
|
||||||
"max_x": 10,
|
"max_x": 0,
|
||||||
"max_y": 10,
|
"max_y": 0,
|
||||||
"simple": true,
|
"simple": true,
|
||||||
"frames": 1,
|
"frames": 1,
|
||||||
"speed": 0.01,
|
"speed": 0.01,
|
||||||
|
|
|
||||||
17
camera.cpp
17
camera.cpp
|
|
@ -40,15 +40,22 @@ namespace cinematic {
|
||||||
anim = MGR.animations.at(name);
|
anim = MGR.animations.at(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Camera::position(float x, float y) {
|
void Camera::focus(float x, float y) {
|
||||||
anim.min_x = x;
|
position.x = x;
|
||||||
anim.min_y = y;
|
position.y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Camera::move(sf::RenderTexture& target, sf::Vector2f pos) {
|
void Camera::move(sf::RenderTexture& target, sf::Vector2f pos) {
|
||||||
sf::View zoom;
|
sf::View zoom;
|
||||||
anim.max_x = pos.x;
|
|
||||||
anim.max_y = pos.y;
|
// BUG: annoying special case
|
||||||
|
if(anim.motion == ease::SLIDE) {
|
||||||
|
anim.min_x = position.x;
|
||||||
|
anim.min_y = position.y;
|
||||||
|
anim.max_x = pos.x;
|
||||||
|
anim.max_y = pos.y;
|
||||||
|
}
|
||||||
|
|
||||||
anim.apply(zoom, pos, size);
|
anim.apply(zoom, pos, size);
|
||||||
target.setView(zoom);
|
target.setView(zoom);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ namespace cinematic {
|
||||||
components::Animation anim;
|
components::Animation anim;
|
||||||
sf::View view;
|
sf::View view;
|
||||||
sf::Vector2f size;
|
sf::Vector2f size;
|
||||||
|
sf::Vector2f position;
|
||||||
|
|
||||||
Camera();
|
Camera();
|
||||||
|
|
||||||
|
|
@ -14,7 +15,7 @@ namespace cinematic {
|
||||||
void move(sf::RenderTexture& target, sf::Vector2f pos);
|
void move(sf::RenderTexture& target, sf::Vector2f pos);
|
||||||
bool playing();
|
bool playing();
|
||||||
void play();
|
void play();
|
||||||
void position(float x, float y);
|
void focus(float x, float y);
|
||||||
void style(const std::string &name);
|
void style(const std::string &name);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
2
main.cpp
2
main.cpp
|
|
@ -20,7 +20,7 @@ int main(int argc, char* argv[]) {
|
||||||
cinematic::init();
|
cinematic::init();
|
||||||
GameDB::init();
|
GameDB::init();
|
||||||
|
|
||||||
if(DEBUG_BUILD) sound::mute(true);
|
sound::mute(true);
|
||||||
|
|
||||||
gui::FSM main;
|
gui::FSM main;
|
||||||
main.event(gui::Event::STARTED);
|
main.event(gui::Event::STARTED);
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ namespace storyboard {
|
||||||
|
|
||||||
bool UI::mouse(float x, float y, guecs::Modifiers mods) {
|
bool UI::mouse(float x, float y, guecs::Modifiers mods) {
|
||||||
auto& cell = $ui.cell_for($zoom_target);
|
auto& cell = $ui.cell_for($zoom_target);
|
||||||
$camera.position(cell.mid_x, cell.mid_y);
|
$camera.focus(cell.mid_x, cell.mid_y);
|
||||||
|
|
||||||
$zoom_target = *$ui.$parser.hit(x, y);
|
$zoom_target = *$ui.$parser.hit(x, y);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue