diff options
author | nathansmithsmith <nathansmith7@mailfence.com> | 2023-08-03 00:11:48 -0600 |
---|---|---|
committer | nathansmithsmith <nathansmith7@mailfence.com> | 2023-08-03 00:11:48 -0600 |
commit | 6d7842484434d1d3f4265194ba87db6afff3186b (patch) | |
tree | 07d9307c500ae47c9c250a2cb8ec24104c78a94b /src/entities | |
parent | 7259478c55bcf1eb717ee1b846522121ef5fd7f3 (diff) |
Working on circle thingy
Diffstat (limited to 'src/entities')
-rw-r--r-- | src/entities/antifaShip.c | 2 | ||||
-rw-r--r-- | src/entities/maresciallo.c | 14 | ||||
-rw-r--r-- | src/entities/maresciallo.h | 2 |
3 files changed, 15 insertions, 3 deletions
diff --git a/src/entities/antifaShip.c b/src/entities/antifaShip.c index 6c017c8..c91f892 100644 --- a/src/entities/antifaShip.c +++ b/src/entities/antifaShip.c @@ -102,6 +102,8 @@ void controlAntifaShipKeyboardAndMouse(Game * game, Entity * entity) { mouseStick.z = -mouseStick.y; mouseStick.y = 0.0; } + + printVector2(mouse); entityJoystickControl(entity, mouseStick, data->forwardSpeed); } diff --git a/src/entities/maresciallo.c b/src/entities/maresciallo.c index f447819..288b27e 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 flyAwayPID = (PIDConfig){ - .kP = 1.1, + .kP = 100, // 1.1 .kI = 0.0, .kD = 0.0, .angleMode = false, @@ -61,8 +61,18 @@ void getAwayMaresciallo(Game * game, Entity * entity) { } void circlePlayerMaresciallo(Game * game, Entity * entity) { + float t = GetFrameTime(); Maresciallo * data = (Maresciallo*)entity->data; Entity * player = getEntityFromWorld(game->world, 0); + + Quaternion toEntity = QuaternionFromVector3ToVector3(player->position, entity->position); + Quaternion next = toEntity; + next = QuaternionIdentity(); + + Vector3 target = Vector3Subtract(entity->position, player->position); + target = Vector3RotateByQuaternion(target, next); + + entity->position = Vector3Add(player->position, target); } void updateMaresciallo(Game * game, Entity * entity) { @@ -72,7 +82,7 @@ void updateMaresciallo(Game * game, Entity * entity) { Entity * player = getEntityFromWorld(game->world, 0); // Fly away if to close to player. - if (Vector3Distance(entity->position, player->position) < MARESCIALLO_CIRCLE_AT_DIS) { + if (Vector3Distance(entity->position, player->position) < MARESCIALLO_CIRCLE_AT_DIS - 1) { getAwayMaresciallo(game, entity); } else { circlePlayerMaresciallo(game, entity); diff --git a/src/entities/maresciallo.h b/src/entities/maresciallo.h index 7492751..e607ab3 100644 --- a/src/entities/maresciallo.h +++ b/src/entities/maresciallo.h @@ -4,7 +4,7 @@ #ifndef MARESCIALLO_H #define MARESCIALLO_H -#define MARESCIALLO_CIRCLE_AT_DIS 200.0 +#define MARESCIALLO_CIRCLE_AT_DIS 50.0 // 200.0 typedef struct Maresciallo { EntityFlyToPointInfo flyAway; |