aboutsummaryrefslogtreecommitdiff
path: root/src/entities/antifaShip.c
diff options
context:
space:
mode:
authornathansmithsmith <nathansmith7@mailfence.com>2023-10-28 16:45:35 -0600
committernathansmithsmith <nathansmith7@mailfence.com>2023-10-28 16:45:35 -0600
commita143a9e7b5ce7b47f4d2c56b250e089b88a888b5 (patch)
treed364daa65d9e3e0b6b415ab47174e237b899f8e4 /src/entities/antifaShip.c
parent60fce38926856e1842aab7c14be99336f34b733f (diff)
Things change color so you know when its on target
Diffstat (limited to 'src/entities/antifaShip.c')
-rw-r--r--src/entities/antifaShip.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/entities/antifaShip.c b/src/entities/antifaShip.c
index f2e885b..34d394b 100644
--- a/src/entities/antifaShip.c
+++ b/src/entities/antifaShip.c
@@ -33,6 +33,7 @@ void initAntifaShip(Entity * entity, Game * game) {
data->timeSinceLastBullet = GetTime();
data->doAutoTarget = false;
data->targetedEntityId = ENTITY_NONE;
+ data->isOnTarget = false;
}
// Go back to burger king you elon musking loving mother fucker!
@@ -111,7 +112,11 @@ void updateAntifaShipTarget(Game * game, Entity * entity) {
// Update target.
float speed = powf(ANTIFA_TARGETING_SPEED / aimDistance, 2.0);
data->gunTarget = Vector3Lerp(data->gunTarget, directionToTarget, speed * t);
+
+ // Is on target.
+ data->isOnTarget = traceRayToEntity(*targetEntity, (Ray){entity->position, data->gunTarget}).hit;
} else {
+ data->isOnTarget = false;
data->gunTarget = Vector3RotateByQuaternion((Vector3){0.0, 0.0, 1.0}, entity->rotation);
}
}
@@ -262,9 +267,17 @@ void drawAntifaShip(Game * game, Entity * entity) {
// Draw bullet.
AntifaShip * data = (AntifaShip*)entity->data;
- // Debug targetting.
- if (data->doAutoTarget)
- DrawLine3D(entity->position, Vector3Add(Vector3Scale(data->gunTarget, 100), entity->position), YELLOW);
+ // Auto target line.
+ if (data->doAutoTarget) {
+ Entity * targetedEntity = getEntityFromWorld(game->world, data->targetedEntityId);
+
+ if (targetedEntity != NULL)
+ DrawLine3D(
+ entity->position,
+ targetedEntity->position,
+ data->isOnTarget ? RED : BLUE
+ );
+ }
if (IsMouseButtonDown(MOUSE_RIGHT_BUTTON))
DrawCylinderWiresEx(
@@ -279,6 +292,7 @@ void drawAntifaShip(Game * game, Entity * entity) {
BLUE
);
+ // Draw bullet being shot.
if (GetTime() - data->timeSinceLastBullet <= ANTIFA_DRAW_BULLET_FOR)
- DrawRay(data->lastBulletShot.ray, BLUE);
+ DrawRay(data->lastBulletShot.ray, RED);
}