diff options
author | nathansmithsmith <nathansmith7@mailfence.com> | 2023-08-09 21:53:50 -0600 |
---|---|---|
committer | nathansmithsmith <nathansmith7@mailfence.com> | 2023-08-09 21:53:50 -0600 |
commit | 87b86d92c27a6fb83d0d09365a36d8a98ba0b24b (patch) | |
tree | 7f5d6325eff8ceca912b437228b1441ff6f7a9b5 /src | |
parent | f12d27b1d87d3bf436abb8ded2d16b8c01746138 (diff) |
Added mussolini face player thingy
Diffstat (limited to 'src')
-rw-r--r-- | src/entities/generale.c | 10 | ||||
-rw-r--r-- | src/entities/mussolini.c | 28 | ||||
-rw-r--r-- | src/entities/mussolini.h | 5 | ||||
-rw-r--r-- | src/game.c | 2 | ||||
-rw-r--r-- | src/playerCamera.c | 6 |
5 files changed, 28 insertions, 23 deletions
diff --git a/src/entities/generale.c b/src/entities/generale.c index 39f38c1..728d9aa 100644 --- a/src/entities/generale.c +++ b/src/entities/generale.c @@ -8,6 +8,11 @@ void initGenerale(Entity * entity, Game * game) { entity->transformedCollisionModel = entityCreateCollisionModel(*entity->model); setEntityRadius(entity); + entity->velocity.angularVelocity = (AxisAngle){ + .axis = (Vector3){0.0, 1.0, 0.0}, + .angle = PI/2.0 + }; + // Allocate data. entity->data = KF_MALLOC(sizeof(Generale)); @@ -47,7 +52,7 @@ void updateGenerale(Game * game, Entity * entity) { if (data->targetNotSet) { getTargetGenerale(game, entity); data->targetNotSet = false; - } else if (Vector3Distance(entity->position, data->target) <= GENERALE_NEXT_POINT_THRESHOLD ) + } else if (Vector3Distance(entity->position, data->target) <= GENERALE_NEXT_POINT_THRESHOLD) getTargetGenerale(game, entity); entityFlyToPoint( @@ -56,6 +61,9 @@ void updateGenerale(Game * game, Entity * entity) { &data->flyToPoint ); + // Spin this fucker. + entityUpdateRotation(entity); + entityCheckTransformedCollisionModel(entity); } diff --git a/src/entities/mussolini.c b/src/entities/mussolini.c index ed6d182..9f56aa3 100644 --- a/src/entities/mussolini.c +++ b/src/entities/mussolini.c @@ -5,19 +5,10 @@ void initMussolini(Entity * entity, Game * game) { entity->model = &game->assets.models[MUSSOLINI_ASSET]; + entity->collisionModel = entityCreateCollisionModel(*entity->model); + entity->transformedCollisionModel = entityCreateCollisionModel(*entity->model); setEntityRadius(entity); - // PID configs. - PIDConfig stickPIDConfig = { - .kP = 0.5, - .kI = 0.0, - .kD = 0.0, - .angleMode = false, - .doClamp = false, - .min = 0.0, - .max = 0.0 - }; - // Allocate data. entity->data = KF_MALLOC(sizeof(Mussolini)); @@ -27,9 +18,6 @@ void initMussolini(Entity * entity, Game * game) { } Mussolini * data = (Mussolini*)entity->data; - data->xStickPID = createPID(stickPIDConfig); - data->yStickPID = createPID(stickPIDConfig); - data->zStickPID = createPID(stickPIDConfig); } void closeMussolini(Entity * entity) { @@ -38,8 +26,18 @@ void closeMussolini(Entity * entity) { } void updateMussolini(Game * game, Entity * entity) { - Entity * ship = getEntityFromWorld(game->world, 0); + entityUpdateLastValues(entity); + + float t = GetFrameTime(); + Entity * player = getEntityFromWorld(game->world, 0); Mussolini * data = (Mussolini*)entity->data; + + // Look at player. + Matrix matrix = MatrixLookAt(player->position, entity->position, (Vector3){0.0, 1.0, 0.0}); + Quaternion rotation = QuaternionInvert(QuaternionFromMatrix(matrix)); + entity->rotation = QuaternionSlerp(entity->rotation, rotation, t * MUSSOLINI_TURN_SPEED); + + entityCheckTransformedCollisionModel(entity); } void drawMussolini(Game * game, Entity * entity) { diff --git a/src/entities/mussolini.h b/src/entities/mussolini.h index 46520a7..5238849 100644 --- a/src/entities/mussolini.h +++ b/src/entities/mussolini.h @@ -5,10 +5,9 @@ #ifndef MUSSOLINI_H #define MUSSOLINI_H +#define MUSSOLINI_TURN_SPEED 1.0 + typedef struct Mussolini { - PID xStickPID; - PID yStickPID; - PID zStickPID; } Mussolini; void initMussolini(Entity * entity, Game * game); @@ -35,7 +35,7 @@ void initGame(Game * game) { WorldEntry entries[2] = { (WorldEntry){ENTITY_ANTIFA, (Vector3){0.0, 0.0, 0.0}, QuaternionIdentity()}, - (WorldEntry){ENTITY_GENERALE, (Vector3){0.0, 0.0, 100.0}, QuaternionIdentity()} + (WorldEntry){ENTITY_MUSSOLINI, (Vector3){0.0, 0.0, 100.0}, QuaternionIdentity()} }; addEntriesToWorld( diff --git a/src/playerCamera.c b/src/playerCamera.c index f759166..6b165f3 100644 --- a/src/playerCamera.c +++ b/src/playerCamera.c @@ -23,7 +23,7 @@ void updatePlayerCamera(Camera3D * camera, Game * game) { // Up. camera->up = Vector3RotateByQuaternion((Vector3){0.0, 1.0, 0.0}, player->rotation); - camera->target = player->position; - camera->position = (Vector3){10.0, 10.0, 10.0}; - camera->up = (Vector3){0.0, 1.0, 0.0}; + //camera->target = player->position; + //camera->position = (Vector3){10.0, 10.0, 10.0}; + //camera->up = (Vector3){0.0, 1.0, 0.0}; } |