aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authornathansmithsmith <nathansmith7@mailfence.com>2023-10-13 12:13:30 -0600
committernathansmithsmith <nathansmith7@mailfence.com>2023-10-13 12:13:30 -0600
commitf80670a77eb2680220aad131b62ed2b9cdfdfa2a (patch)
tree1e0667eb51c6491b8b91a3c158648bd9491c7bf7 /src
parentbbb2c70cd1a0603d57d0fc7615ad8994bfaf39bc (diff)
Some more aimming shit
Diffstat (limited to 'src')
-rw-r--r--src/bullets.c1
-rw-r--r--src/entities/antifaShip.c11
-rw-r--r--src/entities/antifaShip.h3
3 files changed, 13 insertions, 2 deletions
diff --git a/src/bullets.c b/src/bullets.c
index bd7fc81..d4a8c0a 100644
--- a/src/bullets.c
+++ b/src/bullets.c
@@ -13,7 +13,6 @@ Bullet createBulletFromEntity(Entity entity, float damage) {
};
}
-
Bullet createBulletFromDirection(Entity entity, Vector3 direction, float damage) {
return (Bullet){
.ray = (Ray){
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;
diff --git a/src/entities/antifaShip.h b/src/entities/antifaShip.h
index 460fe38..c272865 100644
--- a/src/entities/antifaShip.h
+++ b/src/entities/antifaShip.h
@@ -13,8 +13,11 @@ typedef struct AntifaShip {
Vector2 lastMouse;
float forwardSpeed;
bool shouldInitMousePosition;
+
double timeSinceLastBullet;
Bullet lastBulletShot;
+ Vector3 gunTarget;
+ bool doAutoTarget;
} AntifaShip;
void initAntifaShip(Entity * entity, Game * game);