#include "soldato.h" #include "game.h" void initSoldato(Entity * entity, Game * game) { entity->model = &game->assets.models[SOLDATO_ASSET]; // Acceleration. entity->useAcceleration = true; entity->acceleration = (EntityAcceleration){ .speedUp = 5.0, .speedDown = 0.00001 }; // PID configs. PIDConfig speedPIDConfig = { .kP = -0.5, .kI = 0.0, .kD = 0.0, .angleMode = false, .doClamp = true, .min = 0.0, .max = 30.0 }; // Allocate data. entity->data = KF_MALLOC(sizeof(Soldato)); if (entity->data == NULL) { ALLOCATION_ERROR; return; } Soldato * data = (Soldato*)entity->data; data->speedPID = createPID(speedPIDConfig); } void closeSoldato(Entity * entity) { if (entity->data != NULL) KF_FREE(entity->data); } void updateSoldato(Game * game, Entity * entity) { Entity * player = getEntityFromWorld(game->world, 0); Soldato * data = (Soldato*)entity->data; entityFlightToPoint( entity, player->position, &data->speedPID, 5.0 ); } void drawSoldato(Game * game, Entity * entity) { entityDraw(entity); }