aboutsummaryrefslogtreecommitdiff
path: root/src/entities/sergente.c
diff options
context:
space:
mode:
authornathansmithsmith <nathansmith7@mailfence.com>2023-11-10 12:19:50 -0700
committernathansmithsmith <nathansmith7@mailfence.com>2023-11-10 12:19:50 -0700
commit9588ded8d76e720299ad9d1b254409e715164b81 (patch)
tree8f1bac1e904e83b777dc7ab8f3e96e5f83d66465 /src/entities/sergente.c
parentac7470ce5d680caa7fb53c235aea10cba45e1836 (diff)
Making changes to the guns and fine tuning
Diffstat (limited to 'src/entities/sergente.c')
-rw-r--r--src/entities/sergente.c45
1 files changed, 25 insertions, 20 deletions
diff --git a/src/entities/sergente.c b/src/entities/sergente.c
index 36847d6..0721d1e 100644
--- a/src/entities/sergente.c
+++ b/src/entities/sergente.c
@@ -33,6 +33,7 @@ void initSergente(Entity * entity, Game * game) {
createSergenteTarget(game, entity);
data->timeSinceLastShot = 0.0;
+ data->gunTarget = Vector3One();
}
void closeSergente(Entity * entity) {
@@ -74,6 +75,10 @@ void updateGunsSergente(Game * game, Entity * entity) {
Entity * player = getEntityFromWorld(game->world, 0);
Bullet shot;
+ // Update the fucking gun target.
+ Vector3 target = Vector3Normalize(Vector3Subtract(player->position, entity->position));
+ data->gunTarget = Vector3Lerp(data->gunTarget, target, GetFrameTime() * SERGENTE_GUN_TARGETING_SPEED);
+
// Cool down.
if (t - data->timeSinceLastShot < SERGENTE_COOL_DOWN)
return;
@@ -81,14 +86,12 @@ void updateGunsSergente(Game * game, Entity * entity) {
// We will use random numbers later.
SetRandomSeed(time(NULL));
- // Get direction to player.
- Vector3 dirToPlayer = Vector3Subtract(player->position, entity->position);
- dirToPlayer = Vector3Normalize(dirToPlayer);
+ // Direction shit.
Vector3 direction;
// Shot the shots because this is a fucking shot gun.
for (i = 0; i < SERGENTE_SHOT_COUNT; ++i) {
- direction = Vector3Add(dirToPlayer, getSergenteShotSpread());
+ direction = Vector3Add(data->gunTarget, getSergenteShotSpread());
// Create shot.
shot = createBulletFromDirection(*entity, direction, SERGENTE_DAMAGE);
@@ -123,27 +126,29 @@ void updateSergente(Game * game, Entity * entity) {
void drawSergente(Game * game, Entity * entity) {
entityDraw(entity);
+ /*
// Debug shots
- // int i;
- // Sergente * data = (Sergente*)entity->data;
- //
- // for (i = 0; i < SERGENTE_SHOT_COUNT; ++i) {
- // DrawRay(data->shots[i].ray, BLUE);
- // DrawCube(data->shots[i].ray.position, 1.0, 1.0, 1.0, BLUE);
- // }
+ int i;
+ Sergente * data = (Sergente*)entity->data;
+
+ for (i = 0; i < SERGENTE_SHOT_COUNT; ++i) {
+ DrawRay(data->shots[i].ray, BLUE);
+ DrawCube(data->shots[i].ray.position, 1.0, 1.0, 1.0, BLUE);
+ }
// Test if facing player always.
- //DrawLine3D(
- // entity->position,
- // Vector3Add(
- // entity->position,
- // Vector3Scale(Vector3RotateByQuaternion((Vector3){0.0, 0.0, 1.0}, entity->rotation), 500.0)
- // ),
- // BLUE
- //);
+ DrawLine3D(
+ entity->position,
+ Vector3Add(
+ entity->position,
+ Vector3Scale(Vector3RotateByQuaternion((Vector3){0.0, 0.0, 1.0}, entity->rotation), 500.0)
+ ),
+ BLUE
+ );
// The fucking debug line.
- //DrawLine3D(entity->position, ((Sergente*)entity->data)->target, BLUE);
+ DrawLine3D(entity->position, ((Sergente*)entity->data)->target, BLUE);
+ */
}
void comeBackToPlayerSergente(Game * game, Entity * entity) {