#include "mussolini.h" #include "assets.h" #include "game.h" #include "util.h" 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); // Allocate data. entity->data = KF_MALLOC(sizeof(Mussolini)); if (entity->data == NULL) { ALLOCATION_ERROR; return; } Mussolini * data = (Mussolini*)entity->data; } void closeMussolini(Entity * entity) { if (entity->data != NULL) KF_FREE(entity->data); } void updateMussolini(Game * game, Entity * entity) { 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) { entityDraw(entity); }