diff options
author | nathansmithsmith <nathansmith7@mailfence.com> | 2023-09-25 21:44:19 -0600 |
---|---|---|
committer | nathansmithsmith <nathansmith7@mailfence.com> | 2023-09-25 21:44:19 -0600 |
commit | badfbb1ff98026a4433a146f9caa433be3a46785 (patch) | |
tree | f77d3269d0d82c0cdb0b208f82ad4d0a263d2b8d /src | |
parent | 6f7b9d89c4e65e99196a751e4c43711a573e9eb4 (diff) |
debug camera added
Diffstat (limited to 'src')
-rw-r--r-- | src/cameras.c | 22 | ||||
-rw-r--r-- | src/cameras.h | 7 | ||||
-rw-r--r-- | src/gameScreen.c | 3 |
3 files changed, 27 insertions, 5 deletions
diff --git a/src/cameras.c b/src/cameras.c index 1cf6cee..dc1afd0 100644 --- a/src/cameras.c +++ b/src/cameras.c @@ -19,6 +19,7 @@ void updateFirstPersonCamera(Game * game, Camera3D * camera) { camera->up = Vector3RotateByQuaternion((Vector3){0.0, 1.0, 0.0}, player->rotation); } +// Third person hehehe. void initThirdPersonCamera(Game * game, Camera3D * camera) { *camera = (Camera3D){ .fovy = 90.0, @@ -35,15 +36,32 @@ void updateThirdPersonCamera(Game * game, Camera3D * camera) { camera->up = Vector3RotateByQuaternion((Vector3){0.0, 1.0, 0.0}, player->rotation); } +// KILL THE BUGS!!! +void initDebugCamera(Game * game, Camera3D * camera) { + *camera = (Camera3D){ + .fovy = 120.0, + .projection = CAMERA_PERSPECTIVE, + .position = DEBUG_CAMERA_POSITION, + .up = (Vector3){0.0, 1.0, 0.0} + }; +} + +void updateDebugCamera(Game * game, Camera3D * camera) { + Entity * player = getEntityFromWorld(game->world, 0); + camera->target = player->position; +} + // Callbacks indeed. const CameraInitCb cameraInitCallbacks[CAMERA_COUNT] = { initFirstPersonCamera, - initThirdPersonCamera + initThirdPersonCamera, + initDebugCamera }; const CameraCb cameraCallbacks[CAMERA_COUNT] = { updateFirstPersonCamera, - updateThirdPersonCamera + updateThirdPersonCamera, + updateDebugCamera }; void initCameras(Game * game, Cameras cameras) { diff --git a/src/cameras.h b/src/cameras.h index debd658..dca91ee 100644 --- a/src/cameras.h +++ b/src/cameras.h @@ -4,10 +4,10 @@ #define CAMERAS_H #define FIRST_PERSON_CAMERA_DISTANCE 5.0 - #define THIRD_PERSON_CAMERA_DISTANCE (Vector3){0.0, 10.0, -20.0} +#define DEBUG_CAMERA_POSITION (Vector3){0.0, 200.0, 100.0} -#define CAMERA_COUNT 2 +#define CAMERA_COUNT 3 // Each camera has a game loop callback and a init callback. typedef void (*CameraInitCb)(Game * game, Camera3D * camera); @@ -18,7 +18,8 @@ extern const CameraCb cameraCallbacks[CAMERA_COUNT]; typedef enum CameraId { FIRST_PERSON_CAMERA, - THIRD_PERSON_CAMERA + THIRD_PERSON_CAMERA, + DEBUG_CAMERA } CameraId; // A array of the cameras. diff --git a/src/gameScreen.c b/src/gameScreen.c index 35e495d..ba5981a 100644 --- a/src/gameScreen.c +++ b/src/gameScreen.c @@ -97,6 +97,9 @@ void handleGameScreenInput(Game * game, GameScreen * gameScreen) { case KEY_TWO: gameScreen->mainCamera = THIRD_PERSON_CAMERA; break; + case KEY_THREE: + gameScreen->mainCamera = DEBUG_CAMERA; + break; default: break; } |