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 | |
parent | 7259478c55bcf1eb717ee1b846522121ef5fd7f3 (diff) |
Working on circle thingy
Diffstat (limited to 'src')
-rw-r--r-- | src/entities/antifaShip.c | 2 | ||||
-rw-r--r-- | src/entities/maresciallo.c | 14 | ||||
-rw-r--r-- | src/entities/maresciallo.h | 2 | ||||
-rw-r--r-- | src/gameCommon.h | 1 | ||||
-rw-r--r-- | src/settings.c | 2 | ||||
-rw-r--r-- | src/util.c | 3 | ||||
-rw-r--r-- | src/util.h | 1 |
7 files changed, 21 insertions, 4 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; diff --git a/src/gameCommon.h b/src/gameCommon.h index 0f2a049..0186e35 100644 --- a/src/gameCommon.h +++ b/src/gameCommon.h @@ -7,6 +7,7 @@ #include <ctype.h> #include <stdbool.h> #include <limits.h> +#include <float.h> #include <raylib.h> #include <raymath.h> diff --git a/src/settings.c b/src/settings.c index 5b91f65..16c1ec3 100644 --- a/src/settings.c +++ b/src/settings.c @@ -2,7 +2,7 @@ void initSettings(Settings * settings) { *settings = (Settings){ - .controlMode = JOYSTICK_CONTROL, + .controlMode = KEYBOARD_AND_MOUSE_CONTROL, .mouseSensitivity = 0.05, .scrollBarSpeed = 10.0, .gamePadNum = 0, @@ -17,6 +17,9 @@ void printVector3(Vector3 v) { printf("%f %f %f\n", v.x, v.y, v.z); } +void printVector2(Vector2 v) { + printf("%f %f\n", v.x, v.y); +} // Warning. Mostly chatgpt written. @@ -22,6 +22,7 @@ float signum(float n); // Debugging stuff. void printVector3(Vector3 v); +void printVector2(Vector2 v); // Thank you chatgpt. bool checkTriangleCollision3D(const Triangle3D triangleA, const Triangle3D triangleB, Vector3 normalA, Vector3 normalB); |