Animated scenes can easily make floors that do things, floors with moving elements, but I need to improve the easing/motion parts of the animations.

This commit is contained in:
Zed A. Shaw 2025-10-24 00:24:29 -04:00
parent 2d836a9e2a
commit f8158a3ea9
4 changed files with 23 additions and 21 deletions

View file

@ -6,8 +6,6 @@ const bool DEBUG=false;
const bool YOU_REMOVED_MID_CELL_IDIOT=false;
namespace scene {
using namespace guecs;
Element config_scene_element(nlohmann::json& config, bool and_play, bool duped) {
std::string sprite_name = config["sprite"];
auto st = textures::get_sprite(sprite_name, duped);
@ -26,7 +24,9 @@ namespace scene {
std::string cell = config["cell"];
std::string name = config["name"];
return {name, st, anim, cell, scale_x, scale_y, x, y};
bool at_mid = config["at_mid"];
return {name, st, anim, cell, scale_x, scale_y, x, y, at_mid};
}
Engine::Engine(components::AnimatedScene& scene) :
@ -52,24 +52,24 @@ namespace scene {
void Engine::init() {
$ui.position(SCREEN_WIDTH-BOSS_VIEW_WIDTH,0, BOSS_VIEW_WIDTH, SCREEN_HEIGHT);
$ui.set<Background>($ui.MAIN, {$ui.$parser, THEME.TRANSPARENT});
auto& background = $ui.get<Background>($ui.MAIN);
$ui.set<guecs::Background>($ui.MAIN, {$ui.$parser, guecs::THEME.TRANSPARENT});
auto& background = $ui.get<guecs::Background>($ui.MAIN);
background.set_sprite($scene.background, true);
$ui.layout($layout);
for(auto& actor : $actors) {
actor.pos = position_sprite(actor.st, actor.cell,
actor.scale_x, actor.scale_y, false, actor.x, actor.y);
actor.scale_x, actor.scale_y, actor.at_mid, actor.x, actor.y);
}
for(auto& fixture : $fixtures) {
fixture.pos = position_sprite(fixture.st, fixture.cell,
fixture.scale_x, fixture.scale_y, false, fixture.x, fixture.y);
fixture.scale_x, fixture.scale_y, fixture.at_mid, fixture.x, fixture.y);
}
}
bool Engine::mouse(float x, float y, Modifiers mods) {
bool Engine::mouse(float x, float y, guecs::Modifiers mods) {
return $ui.mouse(x, y, mods);
}
@ -90,7 +90,7 @@ namespace scene {
void Engine::move_actor(const std::string& actor, const std::string& cell_name) {
auto& config = $actors.at($actor_name_ids.at(actor));
config.cell = cell_name;
config.pos = position_sprite(config.st, config.cell, config.scale_x, config.scale_y, YOU_REMOVED_MID_CELL_IDIOT);
config.pos = position_sprite(config.st, config.cell, config.scale_x, config.scale_y, config.at_mid);
}
void Engine::animate_actor(const std::string& actor) {