feat(anim): cardinal WEST i flip totalment governat pel motor d'animació

This commit is contained in:
JailDesigner committed 2026-04-29 10:11:27 +02:00
1 parent 9dc7ff0da3
commit 72384c3113
15 files changed
+183 -182

No files matched your search

+6 -13
View File
@@ -4,9 +4,9 @@
// de càrrega del YAML, no el render real.
//
// Tests coberts:
// T1 backward compat — YAML sense cap flip declarat carrega tots els
// frames amb (flip_h=false, flip_v=false) i sense
// que l'animació prengui control del flip.
// T1 default — YAML sense cap flip declarat carrega tots els frames
// amb (flip_h=false, flip_v=false). L'aplicació al sprite
// resulta en `SDL_FLIP_NONE`.
// T2 flip a nivell d'animació — `flip_h: true` amb frames `int` →
// tots els frames hereten flip_h=true.
// T3 override per-frame — frame mapping `{ index: N, flip_h: true }`
@@ -55,8 +55,8 @@ namespace {
fkyaml::node::deserialize(yaml_str), sheetParams());
}
void testBackwardCompat() {
std::cout << "[T1] backward compat: cap flip declarat\n";
void testDefaultNoFlip() {
std::cout << "[T1] default: cap flip declarat → frames sense flip\n";
const std::string YAML = R"(
animations:
walk: { frames: [0, 1, 2, 3], frame_ms: 100 }
@@ -70,7 +70,6 @@ animations:
if (WALK_IT != ANIMS.end()) {
const auto& WALK = WALK_IT->second;
REQUIRE(WALK.frames.size() == 4);
REQUIRE(!WALK.controls_flip);
for (const auto& F : WALK.frames) {
REQUIRE(!F.flip_h);
REQUIRE(!F.flip_v);
@@ -82,7 +81,6 @@ animations:
if (STAND_IT != ANIMS.end()) {
const auto& STAND = STAND_IT->second;
REQUIRE(STAND.frames.size() == 1);
REQUIRE(!STAND.controls_flip);
REQUIRE(!STAND.frames[0].flip_h);
REQUIRE(!STAND.frames[0].flip_v);
}
@@ -100,7 +98,6 @@ animations:
if (IT != ANIMS.end()) {
const auto& A = IT->second;
REQUIRE(A.frames.size() == 4);
REQUIRE(A.controls_flip);
for (const auto& F : A.frames) {
REQUIRE(F.flip_h);
REQUIRE(!F.flip_v);
@@ -126,8 +123,6 @@ animations:
if (IT != ANIMS.end()) {
const auto& A = IT->second;
REQUIRE(A.frames.size() == 4);
// Hi ha un mapping → l'animació pren el control del flip.
REQUIRE(A.controls_flip);
// Els tres primers (int, sense flip a l'anim) → tot a false.
REQUIRE(!A.frames[0].flip_h);
@@ -160,7 +155,6 @@ animations:
if (IT != ANIMS.end()) {
const auto& A = IT->second;
REQUIRE(A.frames.size() == 2);
REQUIRE(A.controls_flip);
// Frame int hereta el flip_h true de l'animació.
REQUIRE(A.frames[0].flip_h);
@@ -188,7 +182,6 @@ animations:
if (IT != ANIMS.end()) {
const auto& A = IT->second;
REQUIRE(A.frames.size() == 1);
REQUIRE(A.controls_flip);
REQUIRE(A.frames[0].flip_h);
REQUIRE(A.frames[0].flip_v);
}
@@ -199,7 +192,7 @@ animations:
auto main() -> int {
std::cout << "== smoke tests: animation flip parser ==\n";
testBackwardCompat();
testDefaultNoFlip();
testFlipAtAnimationLevel();
testOverridePerFrame();
testMappingDoesNotInherit();