Can indicate that a animation is flipped, which will *-1 on the x.

This commit is contained in:
Zed A. Shaw 2025-10-27 23:54:31 -04:00
parent c4fcb41c34
commit 2ecd8528ea
7 changed files with 45 additions and 13 deletions

View file

@ -99,10 +99,13 @@ namespace components {
current = 0; current = 0;
subframe = 0.0f; subframe = 0.0f;
} }
if(flipped) {
scale_out.x *= -1;
}
} }
} }
namespace animation { namespace animation {
using namespace components; using namespace components;
using namespace textures; using namespace textures;

View file

@ -12,7 +12,9 @@
"frames": 5, "frames": 5,
"speed": 0.1, "speed": 0.1,
"stationary": false, "stationary": false,
"flipped": false,
"toggled": false, "toggled": false,
"flipped": false,
"scaled": true, "scaled": true,
"looped": false "looped": false
}, },
@ -30,7 +32,9 @@
"speed": 0.08, "speed": 0.08,
"scaled": true, "scaled": true,
"stationary": false, "stationary": false,
"flipped": false,
"toggled": false, "toggled": false,
"flipped": false,
"looped": false "looped": false
}, },
"female_hand": { "female_hand": {
@ -48,6 +52,7 @@
"scaled": true, "scaled": true,
"stationary": false, "stationary": false,
"toggled": false, "toggled": false,
"flipped": false,
"looped": false "looped": false
}, },
"lightning_animation": { "lightning_animation": {
@ -65,6 +70,7 @@
"scaled": true, "scaled": true,
"stationary": false, "stationary": false,
"toggled": false, "toggled": false,
"flipped": false,
"looped": false "looped": false
}, },
"ritual_crafting_area": { "ritual_crafting_area": {
@ -82,6 +88,7 @@
"speed": 0.2, "speed": 0.2,
"stationary": true, "stationary": true,
"toggled": true, "toggled": true,
"flipped": false,
"looped": false "looped": false
}, },
"peasant_girl_rear_view": { "peasant_girl_rear_view": {
@ -99,6 +106,7 @@
"scaled": true, "scaled": true,
"stationary": true, "stationary": true,
"toggled": false, "toggled": false,
"flipped": false,
"looped": false "looped": false
}, },
"gold_savior": { "gold_savior": {
@ -116,6 +124,7 @@
"scaled": true, "scaled": true,
"stationary": false, "stationary": false,
"toggled": false, "toggled": false,
"flipped": false,
"looped": false "looped": false
}, },
"armored_knight" : { "armored_knight" : {
@ -133,6 +142,7 @@
"scaled": true, "scaled": true,
"stationary": false, "stationary": false,
"toggled": false, "toggled": false,
"flipped": false,
"looped": false "looped": false
}, },
"axe_ranger": { "axe_ranger": {
@ -150,6 +160,7 @@
"scaled": true, "scaled": true,
"stationary": false, "stationary": false,
"toggled": false, "toggled": false,
"flipped": false,
"looped": false "looped": false
}, },
"rat_with_sword": { "rat_with_sword": {
@ -167,6 +178,7 @@
"scaled": true, "scaled": true,
"stationary": false, "stationary": false,
"toggled": true, "toggled": true,
"flipped": false,
"looped": false "looped": false
}, },
"hairy_spider": { "hairy_spider": {
@ -184,6 +196,7 @@
"scaled": true, "scaled": true,
"stationary": false, "stationary": false,
"toggled": false, "toggled": false,
"flipped": false,
"looped": false "looped": false
}, },
"test_boss": { "test_boss": {
@ -201,6 +214,7 @@
"scaled": true, "scaled": true,
"stationary": true, "stationary": true,
"toggled": false, "toggled": false,
"flipped": false,
"looped": false "looped": false
}, },
"rat_king_boss": { "rat_king_boss": {
@ -218,6 +232,7 @@
"scaled": true, "scaled": true,
"stationary": true, "stationary": true,
"toggled": false, "toggled": false,
"flipped": false,
"looped": false "looped": false
}, },
"torch_fixture": { "torch_fixture": {
@ -227,14 +242,15 @@
"ease_rate": 0.5, "ease_rate": 0.5,
"min_x": 0.5, "min_x": 0.5,
"min_y": 0.5, "min_y": 0.5,
"max_x": 0.4, "max_x": 0.5,
"max_y": 0.4, "max_y": 0.5,
"simple": false, "simple": false,
"frames": 3, "frames": 3,
"speed": 0.2, "speed": 0.2,
"scaled": true, "scaled": true,
"stationary": true, "stationary": true,
"toggled": false, "toggled": false,
"flipped": false,
"looped": true "looped": true
}, },
"test_floor": { "test_floor": {
@ -252,6 +268,7 @@
"scaled": true, "scaled": true,
"stationary": true, "stationary": true,
"toggled": false, "toggled": false,
"flipped": false,
"looped": false "looped": false
} }
} }

View file

@ -20,7 +20,8 @@
"scale_y": 0.6, "scale_y": 0.6,
"x": 0, "x": 0,
"y": 0, "y": 0,
"at_mid": false "at_mid": false,
"flipped": false
}, },
{ {
"name": "player", "name": "player",
@ -30,7 +31,8 @@
"scale_y": 0.5, "scale_y": 0.5,
"x": 0, "x": 0,
"y": 0, "y": 0,
"at_mid": false "at_mid": false,
"flipped": false
} }
], ],
"fixtures": [ "fixtures": [
@ -39,20 +41,24 @@
"sprite": "torch_fixture", "sprite": "torch_fixture",
"scale_x": 0.5, "scale_x": 0.5,
"scale_y": 0.5, "scale_y": 0.5,
"flipped": false,
"cell": "torch1", "cell": "torch1",
"x": 66, "x": 66,
"y": -50, "y": -50,
"at_mid": false "at_mid": false,
"flipped": false
}, },
{ {
"name": "torch_fixture", "name": "torch_fixture",
"sprite": "torch_fixture", "sprite": "torch_fixture",
"scale_x": -0.5, "scale_x": 0.5,
"scale_y": 0.5, "scale_y": 0.5,
"flipped": true,
"cell": "torch2", "cell": "torch2",
"x": 132, "x": 132,
"y": -30, "y": -50,
"at_mid": false "at_mid": false,
"flipped": true
} }
] ]
}, },

View file

@ -105,7 +105,7 @@ namespace boss {
break; break;
case ATTACK: { case ATTACK: {
$ui.status(L"BOSS TURN"); $ui.status(L"BOSS TURN");
// $ui.move_actor("boss", run % 10 < 5 ? "boss5" : "boss6"); $ui.move_actor("boss", run % 10 < 5 ? "boss5" : "boss6");
$ui.animate_actor("boss"); $ui.animate_actor("boss");
int attack_id = std::any_cast<int>(data); int attack_id = std::any_cast<int>(data);
boss::System::combat(attack_id); boss::System::combat(attack_id);

View file

@ -129,6 +129,7 @@ namespace components {
bool stationary = false; bool stationary = false;
bool toggled = false; bool toggled = false;
bool looped = false; bool looped = false;
bool flipped = false;
int current = 0; int current = 0;
bool playing = false; bool playing = false;
@ -163,8 +164,10 @@ namespace components {
ENROLL_COMPONENT(Motion, dx, dy, random); ENROLL_COMPONENT(Motion, dx, dy, random);
ENROLL_COMPONENT(Combat, hp, max_hp, damage, dead); ENROLL_COMPONENT(Combat, hp, max_hp, damage, dead);
ENROLL_COMPONENT(Device, config, events); ENROLL_COMPONENT(Device, config, events);
ENROLL_COMPONENT(Animation, min_x, min_y, max_x, max_y, simple, frames, ENROLL_COMPONENT(Animation, min_x, min_y,
speed, easing, motion, ease_rate, scaled, stationary, toggled, looped); max_x, max_y, simple, frames,
speed, easing, motion, ease_rate,
scaled, stationary, toggled, looped, flipped);
ENROLL_COMPONENT(Sound, attack, death); ENROLL_COMPONENT(Sound, attack, death);
ENROLL_COMPONENT(Collision, has); ENROLL_COMPONENT(Collision, has);

View file

@ -13,9 +13,11 @@ namespace scene {
float scale_y = config["scale_y"]; float scale_y = config["scale_y"];
float x = config["x"]; float x = config["x"];
float y = config["y"]; float y = config["y"];
bool flipped = config["flipped"];
// BUG: need to make animation optional // BUG: need to make animation optional
auto anim = animation::load(sprite_name); auto anim = animation::load(sprite_name);
anim.flipped = flipped;
if(and_play) anim.play(); if(and_play) anim.play();
std::string cell = config["cell"]; std::string cell = config["cell"];
@ -23,7 +25,7 @@ namespace scene {
bool at_mid = config["at_mid"]; bool at_mid = config["at_mid"];
return {name, st, anim, cell, scale_x, scale_y, x, y, at_mid}; return {name, st, anim, cell, scale_x, scale_y, x, y, at_mid, flipped};
} }
Engine::Engine(components::AnimatedScene& scene) : Engine::Engine(components::AnimatedScene& scene) :

View file

@ -20,6 +20,7 @@ namespace scene {
float x = 0; float x = 0;
float y = 0; float y = 0;
bool at_mid=false; bool at_mid=false;
bool flipped=false;
sf::Vector2f pos{0,0}; sf::Vector2f pos{0,0};
}; };