X-Git-Url: http://git.localhorst.tv/?p=space.git;a=blobdiff_plain;f=src%2Fai%2FAutopilot.h;fp=src%2Fai%2FAutopilot.h;h=1a814e6c6aaf01de9283746e7db8fe82137d61f3;hp=b15448ea3a117be6469cd533b38be7c96c6275e0;hb=501ffe20da16eaab69e668871001f735697c4a42;hpb=1cb5ed22d7772abe6f9893be90f26f46dbde39f7 diff --git a/src/ai/Autopilot.h b/src/ai/Autopilot.h index b15448e..1a814e6 100644 --- a/src/ai/Autopilot.h +++ b/src/ai/Autopilot.h @@ -20,13 +20,54 @@ public: void Render(Canvas &, const Camera &) const; +private: + // velocity is so small that the next integration makes no difference + bool StandingStill() const; + // can halt within the current frame + bool ReallySlow() const; + // can halt within one second + bool Slow() const; + + // pointing exactly at target + bool FacingTarget() const; + // pointing exactly away from target + bool FacingOpposite() const; + // ship pointing in direction of given normalized vector + bool Facing(Vector) const; + bool OnTarget() const; + + float Speed() const; + float Distance() const; + float DistanceToHalt() const; + bool ReallyClose() const; + bool InBrakingDistance() const; + bool FarAway() const; + + float TargetVelAngle() const; + + // point the ship towards the target + void FaceTarget(); + // point ship into direction of given normalized vector + void Face(Vector); + // stop the ship asap + void Halt(); + // accelerate if it improves moving in given normalized direction + void AccelerateAlong(Vector); + private: Ship *ctrl; const Vector *target; - // cache members for debug drawing - Vector planFrom; - Vector planTo; + float dt; + + Vector dp; + float dist; + Vector normDP; + + float speed; + Vector normVel; + + Vector proj; };