Arena is now using the new animate2 but needs to be fixed.

This commit is contained in:
Zed A. Shaw 2026-02-11 13:57:19 -05:00
parent 547e8ec993
commit aaf5aa4165
4 changed files with 82 additions and 16 deletions

View file

@ -1,5 +1,5 @@
#include "scene.hpp"
#include "animation.hpp"
#include "animate2.hpp"
#include <ranges>
#include "shaders.hpp"
#include <fmt/core.h>
@ -19,8 +19,8 @@ namespace scene {
bool flipped = config["flipped"];
// BUG: need to make animation optional
auto anim = animation::load(sprite_name);
anim.flipped = flipped;
auto anim = animate2::load("./assets/animate2.json", sprite_name);
anim.transform.flipped = flipped;
if(and_play) anim.play();
std::string cell = config["cell"];
@ -127,7 +127,7 @@ namespace scene {
void Engine::play_animations() {
for(auto& fixture : $fixtures) {
if(fixture.anim.playing) {
fixture.anim.apply(*fixture.st.sprite, fixture.pos);
fixture.anim.apply(*fixture.st.sprite);
} else {
fixture.effect = nullptr;
}
@ -135,13 +135,9 @@ namespace scene {
for(auto& actor : $actors) {
if(actor.anim.playing) {
actor.anim.apply(*actor.st.sprite, actor.pos);
actor.anim.apply(actor.text, actor.pos);
if(actor.effect) {
actor.effect->setUniform("u_time", $clock.getElapsedTime().asSeconds());
sf::Vector2f u_resolution{float(actor.anim.frame_width), float(actor.anim.frame_height)};
actor.effect->setUniform("u_resolution", u_resolution);
}
actor.anim.apply(*actor.st.sprite);
// REFACTOR: actor.anim.apply(actor.text, actor.pos);
if(actor.effect != nullptr) actor.anim.apply_effect(actor.effect);
} else {
actor.effect = nullptr;
}
@ -177,9 +173,10 @@ namespace scene {
}
void Engine::set_end_cb(std::function<void()> cb) {
for(auto& actor : $actors) {
actor.anim.end_cb = cb;
}
// REFACTOR:
// for(auto& actor : $actors) {
// actor.anim.end_cb = cb;
// }
}
void Engine::reset(sf::RenderTexture& view) {