From f45d32ca36a0ae85410b3eee61120fa97bf9bd25 Mon Sep 17 00:00:00 2001 From: nathansmithsmith Date: Sat, 4 Nov 2023 21:25:01 -0600 Subject: Game play feeling great --- src/cameras.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'src/cameras.c') 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 }; -- cgit v1.2.3