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;
subframe = 0.0f;
}
if(flipped) {
scale_out.x *= -1;
}
}
}
namespace animation {
using namespace components;
using namespace textures;

View file

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

View file

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

View file

@ -105,7 +105,7 @@ namespace boss {
break;
case ATTACK: {
$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");
int attack_id = std::any_cast<int>(data);
boss::System::combat(attack_id);

View file

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

View file

@ -13,9 +13,11 @@ namespace scene {
float scale_y = config["scale_y"];
float x = config["x"];
float y = config["y"];
bool flipped = config["flipped"];
// BUG: need to make animation optional
auto anim = animation::load(sprite_name);
anim.flipped = flipped;
if(and_play) anim.play();
std::string cell = config["cell"];
@ -23,7 +25,7 @@ namespace scene {
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) :

View file

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