aboutsummaryrefslogtreecommitdiff
path: root/src/entities/maresciallo.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/entities/maresciallo.c')
-rw-r--r--src/entities/maresciallo.c26
1 files changed, 24 insertions, 2 deletions
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);
}