Nimbin[12]?SDL & Graphics / sdl_runtime_compiler / src/entities/player.hpp

sdl_runtime_compiler git · main

SDL3 game for running and compiling code at runtime

sdl3 c++ compiler dlopen cmake · first commit 2026-04-19 · last commit 2026-07-03 (3 months ago) · synced 3 days ago · upstream: git.ide3.de/hsnr/sdl-runtime-compiler

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.gz
src/entities/player.hpp 898 B · 49 lines raw
#pragma once

#include <SDL3/SDL.h>

#include "systems/input_system.hpp"
#include "utils/globals.hpp"

namespace
Nimbin
{

struct PlayerCollision
{
    bool hit_x {};
    bool hit_y {};
    bool hit_z {};
    Vec3 pos   {};
    Vec3 vel   {};
};


struct Player
{
    double _acc_x{};
    double _acc_z{};
public:
    Player();

    Vec3     pos      {};
    Vec3     prev_pos {};
    Vec3     vel      {};

    float    radius   {0.5f};
    float    height   {1.5f};

    int32_t  pitch    {};
    uint32_t yaw      {};
    bool     on_ground{false};

    void   compute_Movement(const FrameInput& input);
    void   add_Look        (int dx, int dy);
    void   apply_Collision (const PlayerCollision& col);
    double get_AccX        () const { return _acc_x; }
    double get_AccZ        () const { return _acc_z; }
    void   respawn         (const Vec3& spawn_pos);
};


} // namespace Nimbin