aboutsummaryrefslogtreecommitdiff
path: root/src/entities
diff options
context:
space:
mode:
authornathansmithsmith <nathansmith7@mailfence.com>2023-09-10 12:20:13 -0600
committernathansmithsmith <nathansmith7@mailfence.com>2023-09-10 12:20:13 -0600
commit061e3371e860d498baf5eb85386fd638ab7f90f9 (patch)
treee7e45636e190517496dbe616cd1d3081e9fe23d5 /src/entities
parent989621071dc8ce292ca8c985cfed887c88f121ce (diff)
Reinstalling linux again lol
Diffstat (limited to 'src/entities')
-rw-r--r--src/entities/guidedMissile.c28
-rw-r--r--src/entities/guidedMissile.h15
-rw-r--r--src/entities/maresciallo.c26
-rw-r--r--src/entities/maresciallo.h4
-rw-r--r--src/entities/sergente.c2
5 files changed, 72 insertions, 3 deletions
diff --git a/src/entities/guidedMissile.c b/src/entities/guidedMissile.c
new file mode 100644
index 0000000..986760f
--- /dev/null
+++ b/src/entities/guidedMissile.c
@@ -0,0 +1,28 @@
+#include "guidedMissile.h"
+#include "assets.h"
+#include "game.h"
+
+void initGuidedMissile(Entity * entity, Game * game) {
+ entity->model = &game->assets.models[MARESCIALLO_ASSET];
+ entity->collisionModel = entityCreateCollisionModel(*entity->model);
+ entity->transformedCollisionModel = entityCreateCollisionModel(*entity->model);
+ setEntityRadius(entity);
+}
+
+void closeGuidedMissile(Entity * entity) {
+ if (entity->data != NULL)
+ KF_FREE(entity->data);
+
+ entityFreeCollisionModel(entity->collisionModel);
+ entityFreeCollisionModel(entity->transformedCollisionModel);
+}
+
+void updateGuidedMissile(Game * game, Entity * entity) {
+ entityUpdateLastValues(entity);
+
+ entityCheckTransformedCollisionModel(entity);
+}
+
+void drawGuidedMissile(Game * game, Entity * entity) {
+ entityDraw(entity);
+} \ No newline at end of file
diff --git a/src/entities/guidedMissile.h b/src/entities/guidedMissile.h
new file mode 100644
index 0000000..edf3fce
--- /dev/null
+++ b/src/entities/guidedMissile.h
@@ -0,0 +1,15 @@
+#include "gameCommon.h"
+#include "entity.h"
+
+#ifndef GUIDED_MISSILE_H
+#define GUIDED_MISSILE_H
+
+typedef struct GuidedMissile {
+} GuidedMissile;
+
+void initGuidedMissile(Entity * entity, Game * game);
+void closeGuidedMissile(Entity * entity);
+void updateGuidedMissile(Game * game, Entity * entity);
+void drawGuidedMissile(Game * game, Entity * entity);
+
+#endif \ No newline at end of file
diff --git a/src/entities/maresciallo.c b/src/entities/maresciallo.c
index a5b0628..34d3377 100644
--- a/src/entities/maresciallo.c
+++ b/src/entities/maresciallo.c
@@ -2,6 +2,8 @@
#include "assets.h"
#include "game.h"
#include "PID.h"
+#include "bullets.h"
+#include <raylib.h>
void initMaresciallo(Entity * entity, Game * game) {
entity->model = &game->assets.models[MARESCIALLO_ASSET];
@@ -19,6 +21,8 @@ void initMaresciallo(Entity * entity, Game * game) {
Maresciallo * data = (Maresciallo*)entity->data;
+ data->timeSinceLastBulletShot = GetTime();
+
PIDConfig flyToPointPID = (PIDConfig){
.kP = 1.1,
.kI = 0.0,
@@ -88,6 +92,22 @@ void circlePlayerMaresciallo(Game * game, Entity * entity) {
entity->rotation = QuaternionSlerp(entity->rotation, rotation, t * MARESCIALLO_ROTATION_SPEED);
}
+// A gun, like one of those things you find in public schools.
+void updateGunMaresciallo(Game * game, Entity * entity) {
+ double t = GetTime();
+ Maresciallo * data = (Maresciallo*)entity->data;
+ Entity * player = getEntityFromWorld(game->world, 0);
+
+ if (t - data->timeSinceLastBulletShot < MARESCIALLO_COOLDOWN)
+ return;
+
+ // Create and shoot bullet.
+ Bullet bullet = createBulletFromEntity(*entity, MARESCIALLO_BULLET_DAMAGE);
+ BulletHitInfo hit = shootBulletAtEntity(player, bullet);
+
+ data->timeSinceLastBulletShot = t;
+}
+
void updateMaresciallo(Game * game, Entity * entity) {
entityUpdateLastValues(entity);
@@ -109,6 +129,8 @@ void updateMaresciallo(Game * game, Entity * entity) {
void drawMaresciallo(Game * game, Entity * entity) {
entityDraw(entity);
- Entity * player = getEntityFromWorld(game->world, 0);
- DrawLine3D(entity->position, player->position, BLUE);
+ updateGunMaresciallo(game, entity);
+
+ // Entity * player = getEntityFromWorld(game->world, 0);
+ // DrawLine3D(entity->position, player->position, BLUE);
}
diff --git a/src/entities/maresciallo.h b/src/entities/maresciallo.h
index 2e50ffe..7624f8f 100644
--- a/src/entities/maresciallo.h
+++ b/src/entities/maresciallo.h
@@ -9,8 +9,12 @@
#define MARESCIALLO_ROTATION_SPEED 20.0
#define MARESCIALLO_CIRCLE_PLAYER_SPEED 1.0
+#define MARESCIALLO_COOLDOWN 1.0
+#define MARESCIALLO_BULLET_DAMAGE 0.01
+
typedef struct Maresciallo {
EntityFlyToPointInfo flyToPoint;
+ double timeSinceLastBulletShot;
} Maresciallo;
void initMaresciallo(Entity * entity, Game * game);
diff --git a/src/entities/sergente.c b/src/entities/sergente.c
index f161622..7c278a4 100644
--- a/src/entities/sergente.c
+++ b/src/entities/sergente.c
@@ -99,7 +99,7 @@ void updateGunsSergente(Game * game, Entity * entity) {
data->shots[i] = shot;
}
- printf("%f\n", (float)hits / SERGENTE_SHOT_COUNT);
+ //printf("%f\n", (float)hits / SERGENTE_SHOT_COUNT);
data->timeSinceLastShot = t;
}