aboutsummaryrefslogtreecommitdiff
path: root/src/entities/missile.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/entities/missile.c')
-rw-r--r--src/entities/missile.c70
1 files changed, 66 insertions, 4 deletions
diff --git a/src/entities/missile.c b/src/entities/missile.c
index c8e22ea..575fbdc 100644
--- a/src/entities/missile.c
+++ b/src/entities/missile.c
@@ -9,9 +9,28 @@ void initMissile(Entity * entity, Game * game) {
entity->collisionModel = entityCreateCollisionModel(*entity->model);
entity->transformedCollisionModel = entityCreateCollisionModel(*entity->model);
setEntityRadius(entity);
+
+ entity->data = KF_MALLOC(sizeof(Missile));
+
+ if (entity->data == NULL) {
+ ALLOCATION_ERROR;
+ return;
+ }
+
+ Missile * data = (Missile*)entity->data;
+
+ data->timeToLive = MISSILE_DEFAULT_TIME_TO_LIVE;
+ data->birthDay = GetTime();
+ data->damage = MISSILE_DEFAULT_DAMAGE;
+ data->boomBoomAt = MISSILE_DEFAULT_BOOM_BOOM_AT;
+
+ entity->velocity.speed = MISSILE_DEFAULT_SPEED;
}
void closeMissile(Entity * entity) {
+ if (entity->data != NULL)
+ KF_FREE(entity->data);
+
entityFreeCollisionModel(entity->collisionModel);
entityFreeCollisionModel(entity->transformedCollisionModel);
}
@@ -19,8 +38,24 @@ void closeMissile(Entity * entity) {
void updateMissile(Game * game, Entity * entity) {
entityUpdateLastValues(entity);
+ Missile * data = (Missile*)entity->data;
+ Entity * player = getEntityFromWorld(game->world, 0);
+
entityUpdatePosition(entity);
+ // Check the count death to death.
+ if (data->timeToLive != MISSILE_LIVE_FOREVER)
+ if (GetTime() - data->birthDay >= data->timeToLive) {
+ missileGoBoomBoom(game, entity);
+ puts("counted downa downasdjkfdjskl down");
+ }
+
+ // We are quite close to the player indeed.
+ if (Vector3Distance(player->position, entity->position) <= data->boomBoomAt) {
+ missileGoBoomBoom(game, entity);
+ puts("you were fucking hit by this big ass missile");
+ }
+
entityCheckTransformedCollisionModel(entity);
}
@@ -28,10 +63,17 @@ void drawMissile(Game * game, Entity * entity) {
entityDraw(entity);
}
-void aimMissileAtTarget(Entity * entity, Vector3 target) {
+void launchMissileAtTarget(Entity * entity, Vector3 target, float speed) {
+ entity->velocity.speed = speed;
setMissileDirection(entity, Vector3Normalize(Vector3Subtract(entity->position, target)));
}
+// Yo Maggie, If you are reading this I want you to know I have a crush on you (:
+// You are a good person to talk to (even though it's mostly me info dumping) and I like your smile.
+// Don't worry if you hurt my feelings ever.
+// I am not in the best head space most of the time but I can take a lot of punches before hitting the ground.
+// Anyone else reading this: GO FUCK YOURSELF YOU MAGA TRUMP WALMART SHOPPPER!!!
+
void setMissileDirection(Entity * entity, Vector3 direction) {
// Get look at matrix and rotation.
Matrix matrix = MatrixLookAt(Vector3Zero(), direction, (Vector3){0.0, 1.0, 0.0});
@@ -39,8 +81,28 @@ void setMissileDirection(Entity * entity, Vector3 direction) {
// Set velocity.
entity->velocity.velocity = (Vector3){
- matrix.m2 * MISSILE_SPEED,
- matrix.m6 * MISSILE_SPEED,
- matrix.m10 * MISSILE_SPEED
+ matrix.m2 * entity->velocity.speed,
+ matrix.m6 * entity->velocity.speed,
+ matrix.m10 * entity->velocity.speed
};
}
+
+void setMissileDamage(Entity * entity, float damage) {
+ ((Missile*)entity->data)->damage = damage;
+}
+
+void setMissileBoomBoomAt(Entity * entity, float boomBoomAt) {
+ ((Missile*)entity->data)->boomBoomAt = boomBoomAt;
+}
+
+void startMissileCountDown(Entity * entity, double timeToLive) {
+ Missile * data = (Missile*)entity->data;
+ data->timeToLive = timeToLive;
+ data->birthDay = GetTime();
+}
+
+// Fucking boom boom time!!!!
+void missileGoBoomBoom(Game * game, Entity * entity) {
+ entity->health = 0.0;
+ puts("boom boom like the boomers");
+}