BAD: This gets the animation to control the camera, but it's a quick hack to prove it works.
This commit is contained in:
parent
cb58bdd955
commit
102c8c36d5
5 changed files with 63 additions and 18 deletions
|
|
@ -36,8 +36,8 @@ namespace components {
|
|||
}
|
||||
|
||||
void Animation::step(sf::Vector2f& scale_out, sf::Vector2f& pos_out, sf::IntRect& rect_out) {
|
||||
dbc::check(rect_out.size.x > 0, "invalid frame width in animation");
|
||||
dbc::check(rect_out.size.y > 0, "invalid frame height in animation");
|
||||
dbc::check(rect_out.size.x > 0, "step given rect_out with size.x <= 0, must be >");
|
||||
dbc::check(rect_out.size.y > 0, "step given rect_out with size.y <= 0, must be >");
|
||||
|
||||
if(playing && current < frames) {
|
||||
float tick = twitching();
|
||||
|
|
@ -64,8 +64,6 @@ namespace components {
|
|||
} break;
|
||||
case ease::STRETCH: {
|
||||
scale_out.x = std::lerp(min_x, max_x, tick);
|
||||
fmt::println("scale_x: {} max_scale: {} tick: {} scale_out.x: {}",
|
||||
min_x, max_x, tick, scale_out.x);
|
||||
} break;
|
||||
case ease::GROW: {
|
||||
scale_out.y = std::lerp(min_y, max_y, tick);
|
||||
|
|
@ -151,17 +149,18 @@ namespace animation {
|
|||
try {
|
||||
auto anim = components::convert<Animation>(data);
|
||||
|
||||
dbc::check(sprites.contains(name),
|
||||
fmt::format("animation '{}' doesn't have sprite, spelled wrong in config.json?", name));
|
||||
if(!sprites.contains(name)) {
|
||||
fmt::println("animation '{}' doesn't have sprite, spelled wrong in config.json?", name);
|
||||
} else {
|
||||
auto& sprite_config = sprites[name];
|
||||
|
||||
auto& sprite_config = sprites[name];
|
||||
anim.frame_width = sprite_config["frame_width"];
|
||||
anim.frame_height = sprite_config["frame_height"];
|
||||
|
||||
anim.frame_width = sprite_config["frame_width"];
|
||||
anim.frame_height = sprite_config["frame_height"];
|
||||
|
||||
dbc::check(anim.frame_width > 0 && anim.frame_height > 0,
|
||||
fmt::format("invalid frame width/height for animation: {}",
|
||||
name));
|
||||
dbc::check(anim.frame_width > 0 && anim.frame_height > 0,
|
||||
fmt::format("invalid frame width/height for animation: {}",
|
||||
name));
|
||||
}
|
||||
|
||||
MGR.animations.insert_or_assign(name, anim);
|
||||
} catch(...) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue