sdl_runtime_compiler git · main
SDL3 game for running and compiling code at runtime
C++ 72.3% C 26.2%git clone https://git.christianimmanuel.de/sdl-graphics/sdl_runtime_compiler.gitwget https://git.christianimmanuel.de/sdl-graphics/sdl_runtime_compiler/archive/sdl_runtime_compiler.tar.gzsrc/entities/camera.hpp raw
#pragma once
#include <SDL3/SDL.h>
#include "entities/player.hpp"
#include "utils/config.hpp"
#include "utils/globals.hpp"
namespace
Nimbin
{
struct Camera
{
Vec3 pos {};
Vec3 fwd {};
Vec3 right{};
double yaw_r {};
double pitch_r{};
int32_t pitch {};
uint32_t yaw {};
void sync_FromPlayer(const Player& player)
{
pos = player.prev_pos;
yaw = player.yaw;
pitch = player.pitch;
yaw_r = Config::Physics::binrad * yaw;
pitch_r = Config::Physics::binrad * pitch;
fwd = {
-SDL_sin(yaw_r) * SDL_cos(pitch_r),
SDL_sin(pitch_r),
-SDL_cos(yaw_r) * SDL_cos(pitch_r)
};
right = {
SDL_cos(yaw_r),
0.0,
-SDL_sin(yaw_r)
};
}
};
} // namespace Nimbin