From f3f5fedbf591c10fa675a32103bab9480b42abe8 Mon Sep 17 00:00:00 2001 From: nathansmithsmith Date: Tue, 18 Jul 2023 05:54:30 -0600 Subject: Bullet system added --- src/entities/soldato.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'src/entities/soldato.c') diff --git a/src/entities/soldato.c b/src/entities/soldato.c index 30dfa6b..beec40a 100644 --- a/src/entities/soldato.c +++ b/src/entities/soldato.c @@ -7,19 +7,19 @@ void initSoldato(Entity * entity, Game * game) { // Acceleration. entity->useAcceleration = true; entity->acceleration = (EntityAcceleration){ - .speedUp = 5.0, - .speedDown = 0.00001 + .speedUp = 20.0, + .speedDown = 15.0 }; // PID configs. PIDConfig speedPIDConfig = { - .kP = -0.5, + .kP = 1, .kI = 0.0, .kD = 0.0, .angleMode = false, .doClamp = true, .min = 0.0, - .max = 30.0 + .max = 100.0 }; // Allocate data. @@ -31,7 +31,15 @@ void initSoldato(Entity * entity, Game * game) { } Soldato * data = (Soldato*)entity->data; - data->speedPID = createPID(speedPIDConfig); + + // Create fly to point. + data->flyToPoint = (EntityFlyToPointInfo){ + //.controller.speedPID = createPID(speedPIDConfig), + .controller.bangbang.speed = 20.0, + .controller.bangbang.stopAt = 0.0, + .controlType = ENTITY_FLY_TO_POINT_BANG_BANG, + .rotationSpeed = 0.0 + }; } void closeSoldato(Entity * entity) { @@ -43,11 +51,10 @@ void updateSoldato(Game * game, Entity * entity) { Entity * player = getEntityFromWorld(game->world, 0); Soldato * data = (Soldato*)entity->data; - entityFlightToPoint( + entityFlyToPoint( entity, player->position, - &data->speedPID, - 5.0 + &data->flyToPoint ); } -- cgit v1.2.3