Damage no longer changes the player's animation or applies the full-body shader recoil. Hits only tint the actor; the walk cycle and movement continue uninterrupted. Removed the unused flinch overlay and added a regression test for movement through enemy contact.
50 lines
1.7 KiB
C++
50 lines
1.7 KiB
C++
// Regression: enemy contact must never stop the player from moving.
|
|
// Damage is damage — there is no hitstop / stagger / velocity zeroing in the
|
|
// simulation, so every tick (including the ticks with an active hit flash)
|
|
// advances the player by the full movement step.
|
|
#include <cmath>
|
|
#include <cstdio>
|
|
|
|
#include "game/game.hpp"
|
|
|
|
namespace {
|
|
|
|
constexpr float kDt = 1.0f / 60.0f;
|
|
constexpr int kTicks = 90;
|
|
|
|
} // namespace
|
|
|
|
int main() {
|
|
Game game(42);
|
|
game.player.pos = {0.0f, 0.0f};
|
|
game.enemy_system.clear();
|
|
// Spawn on top of the player so contact (and damage) happens at once.
|
|
game.enemy_system.spawn(EnemyType::HissBrute, {0.0f, 0.0f}, game.corruption);
|
|
|
|
InputState in{};
|
|
in.move_x = 1.0f;
|
|
const float expected_step = game.player.stats.move_speed * kDt;
|
|
|
|
bool damaged = false;
|
|
bool stalled = false;
|
|
float previous_x = game.player.pos.x;
|
|
for (int tick = 0; tick < kTicks; ++tick) {
|
|
game.update(in, kDt);
|
|
const float step = game.player.pos.x - previous_x;
|
|
previous_x = game.player.pos.x;
|
|
if (game.player.hit_flash > 0.0f) damaged = true;
|
|
// Allow a little slack for float noise, but a hitstop would drop the
|
|
// step to zero and fail this outright.
|
|
if (step < expected_step * 0.9f) {
|
|
stalled = true;
|
|
std::printf("movement stalled on tick %d: step=%.4f expected=%.4f\n",
|
|
tick, step, expected_step);
|
|
}
|
|
game.events.clear();
|
|
}
|
|
|
|
const float travelled = game.player.pos.x;
|
|
std::printf("damaged=%d stalled=%d travelled=%.3f\n", damaged, stalled, travelled);
|
|
if (!damaged || stalled || travelled < expected_step * kTicks * 0.9f) return 1;
|
|
return 0;
|
|
}
|