diff options
author | nathansmithsmith <nathansmith7@mailfence.com> | 2023-11-04 21:25:01 -0600 |
---|---|---|
committer | nathansmithsmith <nathansmith7@mailfence.com> | 2023-11-04 21:25:01 -0600 |
commit | f45d32ca36a0ae85410b3eee61120fa97bf9bd25 (patch) | |
tree | d2b199bb12e9e9fe967dca415bf1b7270382774a /src/cameras.c | |
parent | 5627fd8128957710c6f16330b2bc1bc3251c5355 (diff) |
Game play feeling great
Diffstat (limited to 'src/cameras.c')
-rw-r--r-- | src/cameras.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/cameras.c b/src/cameras.c index dc1afd0..ca03b51 100644 --- a/src/cameras.c +++ b/src/cameras.c @@ -1,6 +1,7 @@ #include "cameras.h" #include "game.h" #include "world.h" +#include "entitiesInclude.h" // First person camera indeed. void initFirstPersonCamera(Game * game, Camera3D * camera) { @@ -30,12 +31,37 @@ void initThirdPersonCamera(Game * game, Camera3D * camera) { void updateThirdPersonCamera(Game * game, Camera3D * camera) { Entity * player = getEntityFromWorld(game->world, 0); Vector3 direction = Vector3RotateByQuaternion(THIRD_PERSON_CAMERA_DISTANCE, player->rotation); - camera->position = Vector3Add(player->position, direction); + camera->target = player->position; camera->up = Vector3RotateByQuaternion((Vector3){0.0, 1.0, 0.0}, player->rotation); } +// Zoom camera indeed hehehehehehe. +void initZoomCamera(Game * game, Camera3D * camera) { + *camera = (Camera3D){ + .fovy = 12.0, + .projection = CAMERA_PERSPECTIVE + }; +} + +void updateZoomCamera(Game * game, Camera3D * camera) { + Entity * player = getEntityFromWorld(game->world, 0); + AntifaShip * data = (AntifaShip*)player->data; + + Vector3 direction; + + // Get direction. Aim with ship or target on target entity. + if (data->doAutoTarget) + direction = data->gunTarget; + else + direction = Vector3RotateByQuaternion((Vector3){0.0, 0.0, 1.0}, player->rotation); + + camera->position = Vector3Add(player->position, Vector3Scale(direction, FIRST_PERSON_CAMERA_DISTANCE)); + camera->target = Vector3Add(camera->position, direction); + camera->up = Vector3RotateByQuaternion((Vector3){0.0, 1.0, 0.0}, player->rotation); +} + // KILL THE BUGS!!! void initDebugCamera(Game * game, Camera3D * camera) { *camera = (Camera3D){ @@ -55,12 +81,14 @@ void updateDebugCamera(Game * game, Camera3D * camera) { const CameraInitCb cameraInitCallbacks[CAMERA_COUNT] = { initFirstPersonCamera, initThirdPersonCamera, + initZoomCamera, initDebugCamera }; const CameraCb cameraCallbacks[CAMERA_COUNT] = { updateFirstPersonCamera, updateThirdPersonCamera, + updateZoomCamera, updateDebugCamera }; |