diff options
author | nathansmithsmith <nathansmith7@mailfence.com> | 2023-10-13 12:13:30 -0600 |
---|---|---|
committer | nathansmithsmith <nathansmith7@mailfence.com> | 2023-10-13 12:13:30 -0600 |
commit | f80670a77eb2680220aad131b62ed2b9cdfdfa2a (patch) | |
tree | 1e0667eb51c6491b8b91a3c158648bd9491c7bf7 /src/entities/antifaShip.c | |
parent | bbb2c70cd1a0603d57d0fc7615ad8994bfaf39bc (diff) |
Some more aimming shit
Diffstat (limited to 'src/entities/antifaShip.c')
-rw-r--r-- | src/entities/antifaShip.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/entities/antifaShip.c b/src/entities/antifaShip.c index cf63698..e1ab730 100644 --- a/src/entities/antifaShip.c +++ b/src/entities/antifaShip.c @@ -31,6 +31,7 @@ void initAntifaShip(Entity * entity, Game * game) { data->forwardSpeed = 0.0; data->shouldInitMousePosition = true; data->timeSinceLastBullet = GetTime(); + data->doAutoTarget = false; } void closeAntifaShip(Entity * entity) { @@ -41,18 +42,26 @@ void closeAntifaShip(Entity * entity) { entityFreeCollisionModel(entity->transformedCollisionModel); } +void updateAntifaShipTarget(Game * game, Entity * entity) { + AntifaShip * data = (AntifaShip*)entity->data; + + data->gunTarget = Vector3RotateByQuaternion((Vector3){0.0, 0.0, 1.0}, entity->rotation); +} + // This fucker will fire a bullet!!! void fireBulletAntifa(Game * game, Entity * entity) { double t = GetTime(); AntifaShip * data = (AntifaShip*)entity->data; + updateAntifaShipTarget(game, entity); + // Let it cool down. if (t - data->timeSinceLastBullet < ANTIFA_BULLET_COOLDOWN) return; puts("shoot shoot"); - Bullet bullet = createBulletFromEntity(*entity, 1.0); + Bullet bullet = createBulletFromDirection(*entity, data->gunTarget, 1.0); BulletHitInfo info = shootBullet(&game->world, bullet); data->lastBulletShot = bullet; |