From 6411d4eabe48104211be728663afb146dbd12711 Mon Sep 17 00:00:00 2001 From: nathansmithsmith Date: Fri, 4 Aug 2023 14:58:45 -0600 Subject: Started working on generale --- src/entities/generale.c | 38 ++++++++++++++++++++++++++++++++++++-- src/entities/generale.h | 15 +++++++++++++++ src/entities/maresciallo.c | 2 +- 3 files changed, 52 insertions(+), 3 deletions(-) diff --git a/src/entities/generale.c b/src/entities/generale.c index 017f213..4865d4e 100644 --- a/src/entities/generale.c +++ b/src/entities/generale.c @@ -4,17 +4,51 @@ void initGenerale(Entity * entity, Game * game) { entity->model = &game->assets.models[GENERALE_ASSET]; + entity->collisionModel = entityCreateCollisionModel(*entity->model); + entity->transformedCollisionModel = entityCreateCollisionModel(*entity->model); setEntityRadius(entity); - entity->velocity.angularVelocity = (AxisAngle){(Vector3){1.0, 1.0, 1.0}, 1.0}; + + // Allocate data. + entity->data = KF_MALLOC(sizeof(Generale)); + + if (entity->data == NULL) { + ALLOCATION_ERROR; + return; + } + + Generale * data = (Generale*)entity->data; + + data->flyToPoint = (EntityFlyToPointInfo){ + .controller.bangbang.speed = 85.0, + .controller.bangbang.stopAt = 0.0, + .controlType = ENTITY_FLY_TO_POINT_BANG_BANG, + .rotationSpeed = 0.0, + .applyRotation = false + }; + + data->zigzag = GENERALE_ZIG; } void closeGenerale(Entity * entity) { + if (entity->data != NULL) + KF_FREE(entity->data); + + entityFreeCollisionModel(entity->collisionModel); + entityFreeCollisionModel(entity->transformedCollisionModel); } void updateGenerale(Game * game, Entity * entity) { - entityUpdateRotation(entity); + entityUpdateLastValues(entity); + + entityCheckTransformedCollisionModel(entity); } void drawGenerale(Game * game, Entity * entity) { entityDraw(entity); } + +void getTargetGenerale(Game * game, Entity * entity) { + Entity * player = getEntityFromWorld(game->world, 0); + + Vector3 dis = Vector3Subtract( +} diff --git a/src/entities/generale.h b/src/entities/generale.h index 12b1ccb..2266e98 100644 --- a/src/entities/generale.h +++ b/src/entities/generale.h @@ -4,9 +4,24 @@ #ifndef GENERALE_H #define GENERALE_H +#define GENERALE_ZIGZAG_SIZE 10.0 + +typedef enum GeneraleZigZag { + GENERALE_ZIG, + GENERALE_ZAG +} GeneraleZigZag; + +typedef struct Generale { + EntityFlyToPointInfo flyToPoint; + GeneraleZigZag zigzag; + Vector3 target; +} Generale; + void initGenerale(Entity * entity, Game * game); void closeGenerale(Entity * entity); void updateGenerale(Game * game, Entity * entity); void drawGenerale(Game * game, Entity * entity); +void getTargetGenerale(Game * game, Entity * entity); + #endif diff --git a/src/entities/maresciallo.c b/src/entities/maresciallo.c index a302b89..a5b0628 100644 --- a/src/entities/maresciallo.c +++ b/src/entities/maresciallo.c @@ -20,7 +20,7 @@ void initMaresciallo(Entity * entity, Game * game) { Maresciallo * data = (Maresciallo*)entity->data; PIDConfig flyToPointPID = (PIDConfig){ - .kP = 1.1, // 1.1 + .kP = 1.1, .kI = 0.0, .kD = 0.0, .angleMode = false, -- cgit v1.2.3