feat(player): mort i respawn (DYING + death_spinning + lives counter)
This commit is contained in:
1 parent
6397f9d4eb
commit
9f0a566ffb
11 files changed
+377
-7
No files matched your search
@@ -167,6 +167,54 @@ animations:
|
||||
}
|
||||
}
|
||||
|
||||
void testDeathSpinning() {
|
||||
std::cout << "[T6] death_spinning: 12 frames + frame_ms list + loop:false\n";
|
||||
// Mateix bloc que sam.yaml/morcus.yaml. 3 voltes horàries: per
|
||||
// cada volta, sud (idx 0) → oest (idx 8 amb flip_h) → nord (idx 4)
|
||||
// → est (idx 8). 12 frames totals; rampa lineal de durades; sense
|
||||
// loop (es queda al darrer frame).
|
||||
const std::string YAML = R"(
|
||||
animations:
|
||||
death_spinning:
|
||||
frames:
|
||||
- 0
|
||||
- { index: 8, flip_h: true }
|
||||
- 4
|
||||
- 8
|
||||
- 0
|
||||
- { index: 8, flip_h: true }
|
||||
- 4
|
||||
- 8
|
||||
- 0
|
||||
- { index: 8, flip_h: true }
|
||||
- 4
|
||||
- 8
|
||||
frame_ms: [60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280]
|
||||
loop: false
|
||||
)";
|
||||
const auto ANIMS = parse(YAML);
|
||||
const auto IT = ANIMS.find("death_spinning");
|
||||
REQUIRE(IT != ANIMS.end());
|
||||
if (IT == ANIMS.end()) { return; }
|
||||
const auto& A = IT->second;
|
||||
|
||||
REQUIRE(A.frames.size() == 12);
|
||||
REQUIRE(A.speeds.size() == 12);
|
||||
REQUIRE(A.loop_from == -1); // loop:false → -1
|
||||
|
||||
// Patró cíclic: posicions 1,5,9 (oest) tenen flip_h=true; la resta no.
|
||||
for (size_t i = 0; i < A.frames.size(); ++i) {
|
||||
const bool IS_WEST = (i % 4 == 1);
|
||||
REQUIRE(A.frames[i].flip_h == IS_WEST);
|
||||
REQUIRE(!A.frames[i].flip_v);
|
||||
}
|
||||
|
||||
// Rampa de durades creixent (acceleració negativa visual).
|
||||
for (size_t i = 1; i < A.speeds.size(); ++i) {
|
||||
REQUIRE(A.speeds[i] > A.speeds[i - 1]);
|
||||
}
|
||||
}
|
||||
|
||||
void testCombinedVerticalAndHorizontal() {
|
||||
std::cout << "[T5] flip combinat V+H per-frame\n";
|
||||
const std::string YAML = R"(
|
||||
@@ -197,6 +245,7 @@ auto main() -> int {
|
||||
testOverridePerFrame();
|
||||
testMappingDoesNotInherit();
|
||||
testCombinedVerticalAndHorizontal();
|
||||
testDeathSpinning();
|
||||
|
||||
if (g_failures == 0) {
|
||||
std::cout << "ALL OK\n";
|
||||
|
||||
Reference in new issue
Block a user