diff options
author | nathansmithsmith <nathansmith7@mailfence.com> | 2023-10-27 20:15:37 -0600 |
---|---|---|
committer | nathansmithsmith <nathansmith7@mailfence.com> | 2023-10-27 20:15:37 -0600 |
commit | fa14227560c9be143b7c26ada4e41c6636966896 (patch) | |
tree | 0736bb8e301942028f18f1a416dd1b842f116768 /src | |
parent | 4c5b7bdbe8c1cfef9ed7a3ef639f3f83411b2b0e (diff) |
Playing with targeting more
Diffstat (limited to 'src')
-rw-r--r-- | src/entities/antifaShip.c | 20 | ||||
-rw-r--r-- | src/radar.c | 17 | ||||
-rw-r--r-- | src/radar.h | 1 |
3 files changed, 33 insertions, 5 deletions
diff --git a/src/entities/antifaShip.c b/src/entities/antifaShip.c index fbcb138..54f5aa9 100644 --- a/src/entities/antifaShip.c +++ b/src/entities/antifaShip.c @@ -36,7 +36,7 @@ void initAntifaShip(Entity * entity, Game * game) { // Targeting PID indeed (: PIDConfig targetingPIDConfig = (PIDConfig){ - .kP = 500.0, + .kP = 1000.0, .kI = 0.1, .kD = 0.0, .angleMode = false, @@ -272,10 +272,22 @@ void drawAntifaShip(Game * game, Entity * entity) { // Draw bullet. AntifaShip * data = (AntifaShip*)entity->data; - if (data->doAutoTarget) { + // Debug targetting. + if (data->doAutoTarget) DrawLine3D(entity->position, Vector3Add(Vector3Scale(data->gunTarget, 100), entity->position), YELLOW); - //printVector3(data->gunTarget); - } + + if (IsMouseButtonDown(MOUSE_RIGHT_BUTTON)) + DrawCylinderWiresEx( + entity->position, + Vector3Add( + entity->position, + Vector3Scale(Vector3RotateByQuaternion((Vector3){0.0, 0.0, 1.0}, entity->rotation), 10.0) + ), + entity->radius / 2.0, + ANTIFA_START_AUTO_TARGET_MAX * 10.0, + 16, + BLUE + ); if (GetTime() - data->timeSinceLastBullet <= ANTIFA_DRAW_BULLET_FOR) DrawRay(data->lastBulletShot.ray, BLUE); diff --git a/src/radar.c b/src/radar.c index 192617e..19dfe21 100644 --- a/src/radar.c +++ b/src/radar.c @@ -3,6 +3,7 @@ #include "entity.h" #include "world.h" #include "assets.h" +#include "entitiesInclude.h" void initRadar(Radar * radar) { resetRadarPosition(radar); @@ -37,11 +38,18 @@ void drawRadar3DParts(Game * game, Radar * radar) { World * world = &game->world; Entity * player = getEntityFromWorld(*world, 0); + AntifaShip * data = (AntifaShip*)player->data; BeginTextureMode(radar->texture); ClearBackground(RADAR_COLOR); BeginMode3D(radar->camera); + // Get targeted entity if there is one. + Entity * targetedEntity = NULL; + + if (data->doAutoTarget) + targetedEntity = getEntityFromWorld(game->world, data->targetedEntityId); + // Draw entities on radar. Skip player. for (i = 1; i < world->entitiesCount; ++i) { Entity * entity = &world->entities[i]; @@ -50,10 +58,17 @@ void drawRadar3DParts(Game * game, Radar * radar) { if (Vector3Distance(player->position, entity->position) > RADAR_MAX_DISTANCE) continue; + Color color = RADAR_ENTITY_COLOR; + + // Is targeted. + if (targetedEntity != NULL) + if (entity->fingerprint == targetedEntity->fingerprint) + color = RADAR_TARGETED_ENTITY_COLOR; + DrawSphere( Vector3Scale(Vector3Subtract(entity->position, player->position), RADAR_WORLD_SCALE), RADAR_POINT_SIZE, - RADAR_ENTITY_COLOR + color ); } diff --git a/src/radar.h b/src/radar.h index 4719d7b..75b1389 100644 --- a/src/radar.h +++ b/src/radar.h @@ -12,6 +12,7 @@ #define RADAR_COLOR (Color){255, 255, 255, 85} #define RADAR_CROSS_COLOR (Color){YELLOW.r, YELLOW.g, YELLOW.b, 127} #define RADAR_ENTITY_COLOR BLACK +#define RADAR_TARGETED_ENTITY_COLOR RED #define RADAR_PLAYER_COLOR BLUE typedef struct Radar { |