From 061e3371e860d498baf5eb85386fd638ab7f90f9 Mon Sep 17 00:00:00 2001 From: nathansmithsmith Date: Sun, 10 Sep 2023 12:20:13 -0600 Subject: Reinstalling linux again lol --- src/entities/maresciallo.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'src/entities/maresciallo.c') 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 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); } -- cgit v1.2.3