diff options
author | nathansmithsmith <nathansmith7@mailfence.com> | 2023-09-12 21:53:32 -0600 |
---|---|---|
committer | nathansmithsmith <nathansmith7@mailfence.com> | 2023-09-12 21:53:32 -0600 |
commit | 7d4d948dfa92416c802229b1c444a44785ee2a0c (patch) | |
tree | 129fcf7141640ec8b3c7647de174755d04858ce2 /src/entities | |
parent | c759231e1e8570ffe5fdda2f1eb5d011b1c6a29f (diff) |
Guided missile worky worky
Diffstat (limited to 'src/entities')
-rw-r--r-- | src/entities/guidedMissile.c | 16 | ||||
-rw-r--r-- | src/entities/guidedMissile.h | 3 | ||||
-rw-r--r-- | src/entities/maresciallo.c | 9 | ||||
-rw-r--r-- | src/entities/maresciallo.h | 2 |
4 files changed, 26 insertions, 4 deletions
diff --git a/src/entities/guidedMissile.c b/src/entities/guidedMissile.c index 53cbaf8..b7f6b68 100644 --- a/src/entities/guidedMissile.c +++ b/src/entities/guidedMissile.c @@ -18,6 +18,8 @@ void initGuidedMissile(Entity * entity, Game * game) { GuidedMissile * data = (GuidedMissile*)entity->data; + data->beenBorn = false; // NOT EVEN BORN YET! HA HA!!! + data->flyToPoint = (EntityFlyToPointInfo){ .controller.bangbang.speed = 80, .controller.bangbang.stopAt = 0.0, @@ -41,12 +43,24 @@ void updateGuidedMissile(Game * game, Entity * entity) { Entity * player = getEntityFromWorld(game->world, 0); GuidedMissile * data = (GuidedMissile*)entity->data; + // Life begins. + if (!data->beenBorn) { + data->beenBorn = true; + data->birthDay = GetTime(); + } + entityFlyToPoint(entity, player->position, &data->flyToPoint); // boom boom time if (Vector3Distance(player->position, entity->position) <= GUIDED_MISSILE_BOOM_BOOM_AT) guidedMissileGoBoomBoom(game, entity); + // Death countdown. + if (GetTime() - data->birthDay >= GUIDED_MISSILE_DEATH_DAY) { + guidedMissileGoBoomBoom(game, entity); + puts("Me is fucking dead!!!!"); + } + entityCheckTransformedCollisionModel(entity); } @@ -67,5 +81,5 @@ void guidedMissileGoBoomBoom(Game * game, Entity * entity) { // Remove its self from the world. I have thought of doing the same for years ): entity->health = 0.0; - printf("This fucker did %f damage\n", damage); + printf("This fucker died %f damage\n", damage); } diff --git a/src/entities/guidedMissile.h b/src/entities/guidedMissile.h index b184775..8d33e86 100644 --- a/src/entities/guidedMissile.h +++ b/src/entities/guidedMissile.h @@ -9,8 +9,11 @@ #define GUIDED_MISSILE_DAMAGE 2.0 #define GUIDED_MISSILE_BOOM_BOOM_AT 5.0 +#define GUIDED_MISSILE_DEATH_DAY 5.0 // Its like a birth day but sad. typedef struct GuidedMissile { + bool beenBorn; + double birthDay; // Even missiles have birth days. EntityFlyToPointInfo flyToPoint; } GuidedMissile; diff --git a/src/entities/maresciallo.c b/src/entities/maresciallo.c index 34d3377..52c5d96 100644 --- a/src/entities/maresciallo.c +++ b/src/entities/maresciallo.c @@ -105,6 +105,11 @@ void updateGunMaresciallo(Game * game, Entity * entity) { Bullet bullet = createBulletFromEntity(*entity, MARESCIALLO_BULLET_DAMAGE); BulletHitInfo hit = shootBulletAtEntity(player, bullet); + // Testing missile. + Entity missile = createEntity(ENTITY_GUIDED_MISSILE, game); + missile.position = entity->position; + scheduleEntityToAdd(&game->world, missile); + data->timeSinceLastBulletShot = t; } @@ -123,14 +128,14 @@ void updateMaresciallo(Game * game, Entity * entity) { circlePlayerMaresciallo(game, entity); } + updateGunMaresciallo(game, entity); + entityCheckTransformedCollisionModel(entity); } void drawMaresciallo(Game * game, Entity * entity) { entityDraw(entity); - 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 7624f8f..a88910c 100644 --- a/src/entities/maresciallo.h +++ b/src/entities/maresciallo.h @@ -9,7 +9,7 @@ #define MARESCIALLO_ROTATION_SPEED 20.0 #define MARESCIALLO_CIRCLE_PLAYER_SPEED 1.0 -#define MARESCIALLO_COOLDOWN 1.0 +#define MARESCIALLO_COOLDOWN 3.0 #define MARESCIALLO_BULLET_DAMAGE 0.01 typedef struct Maresciallo { |