aboutsummaryrefslogtreecommitdiff
path: root/src/entities
diff options
context:
space:
mode:
authornathansmithsmith <nathansmith7@mailfence.com>2023-09-08 20:26:53 -0600
committernathansmithsmith <nathansmith7@mailfence.com>2023-09-08 20:26:53 -0600
commit989621071dc8ce292ca8c985cfed887c88f121ce (patch)
tree48c3c3bc09327710c973cec8cebdc2dd7de07cb7 /src/entities
parent20be44ab48c3c8ec94f7eecddd48fc0c5ae18c6e (diff)
Played with shot gun thingy a bit more
Diffstat (limited to 'src/entities')
-rw-r--r--src/entities/sergente.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/entities/sergente.c b/src/entities/sergente.c
index 0336355..f161622 100644
--- a/src/entities/sergente.c
+++ b/src/entities/sergente.c
@@ -68,16 +68,11 @@ Vector3 getSergenteShotSpread() {
void updateGunsSergente(Game * game, Entity * entity) {
int i;
+ int hits = 0;
float t = GetTime();
Sergente * data = (Sergente*)entity->data;
Entity * player = getEntityFromWorld(game->world, 0);
- Bullet shots[SERGENTE_SHOT_COUNT];
-
- // debug draw.
- 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);
- }
+ Bullet shot;
// Cool down.
if (t - data->timeSinceLastShot < SERGENTE_COOL_DOWN)
@@ -96,14 +91,16 @@ void updateGunsSergente(Game * game, Entity * entity) {
direction = Vector3Add(dirToPlayer, getSergenteShotSpread());
// Create shot.
- shots[i] = createBulletFromDirection(*entity, direction, SERGENTE_DAMAGE);
+ shot = createBulletFromDirection(*entity, direction, SERGENTE_DAMAGE);
// Shoot it.
- //printf("%d\n", shootBulletAtEntity(player, shots[i]).hit);
+ hits += shootBulletAtEntity(player, shot).hit ? 1 : 0;
- data->shots[i] = shots[i];
+ data->shots[i] = shot;
}
+ printf("%f\n", (float)hits / SERGENTE_SHOT_COUNT);
+
data->timeSinceLastShot = t;
}
@@ -118,14 +115,22 @@ void updateSergente(Game * game, Entity * entity) {
if (Vector3Distance(entity->position, data->target) <= SERGENTE_NEXT_POINT_THRESHOLD)
createSergenteTarget(game, entity);
- //updateRotationSergente(game, entity);
+ updateGunsSergente(game, entity);
+ updateRotationSergente(game, entity);
entityCheckTransformedCollisionModel(entity);
}
void drawSergente(Game * game, Entity * entity) {
entityDraw(entity);
- updateGunsSergente(game, 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);
+ }
// Test if facing player always.
//DrawLine3D(