change to physics based ship movement
This commit is contained in:
@@ -93,13 +93,15 @@ TEST_CASE("BehaviorSystem: clearMovementIntents resets all ships to priority 0",
|
||||
// tickMovement
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
TEST_CASE("BehaviorSystem: tickMovement advances ship by speedPerTick toward target",
|
||||
// With facing=0 and target due east, main thrust drives the ship east. The test
|
||||
// config uses very high thrust so the ship reaches maxSpeedPerTick in one tick.
|
||||
TEST_CASE("BehaviorSystem: tickMovement advances ship by maxSpeedPerTick toward target",
|
||||
"[behavior]")
|
||||
{
|
||||
Fixture f;
|
||||
const EntityId id = f.ships.spawn("interceptor", 1, QVector2D(0.0f, 0.0f));
|
||||
|
||||
const float speed = f.ships.findShip(id)->speedPerTick;
|
||||
const float speed = f.ships.findShip(id)->maxSpeedPerTick;
|
||||
const QVector2D target(100.0f, 0.0f);
|
||||
|
||||
f.ships.forEach([&target](Ship& s) {
|
||||
@@ -112,6 +114,8 @@ TEST_CASE("BehaviorSystem: tickMovement advances ship by speedPerTick toward tar
|
||||
REQUIRE(s->position.y() == Approx(0.0f));
|
||||
}
|
||||
|
||||
// With very high maneuvering thrust the stopping distance is ~0, so desiredSpeed
|
||||
// still exceeds maxSpeedPerTick and the snap-to-target branch fires.
|
||||
TEST_CASE("BehaviorSystem: tickMovement stops exactly at target without overshoot",
|
||||
"[behavior]")
|
||||
{
|
||||
@@ -119,7 +123,7 @@ TEST_CASE("BehaviorSystem: tickMovement stops exactly at target without overshoo
|
||||
const EntityId id = f.ships.spawn("interceptor", 1, QVector2D(0.0f, 0.0f));
|
||||
|
||||
// Place target closer than one tick's travel.
|
||||
const float speed = f.ships.findShip(id)->speedPerTick;
|
||||
const float speed = f.ships.findShip(id)->maxSpeedPerTick;
|
||||
const QVector2D target(speed * 0.5f, 0.0f);
|
||||
|
||||
f.ships.forEach([&target](Ship& s) {
|
||||
|
||||
Reference in New Issue
Block a user