Nimbin[12]?SDL & Graphics / sdl3_3d_oop_basic_game / src/entities/world.hpp

sdl3_3d_oop_basic_game git · main

SDL3 3D OOP basic game (entities, systems, CMake)

sdl3 3d c++ game cmake · first commit 2026-04-19 · last commit 2026-04-19 (7 months ago) · synced 1 hour ago · upstream: git.ide3.de/chfis005/sdl3_3d_oop_basic_game

C++ 99%
git clone https://git.christianimmanuel.de/sdl-graphics/sdl3_3d_oop_basic_game.gitwget https://git.christianimmanuel.de/sdl-graphics/sdl3_3d_oop_basic_game/archive/sdl3_3d_oop_basic_game.tar.gz
src/entities/world.hpp 658 B · 40 lines raw
#pragma once

#include <array>

#include "entities/player.hpp"
#include "entities/camera.hpp"

#define MAP_BOX_SCALE 16
#define MAP_BOX_EDGES_LEN (12 + MAP_BOX_SCALE * 2)

struct Edge {
    Vec3 a;
    Vec3 b;
};

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

class World {
public:
    World();

    PlayerCollision resolvePlayer(const Player& player) const;

    void draw(SDL_Renderer* renderer, const Camera& camera) const;

    Vec3 spawnPoint() const;
    float scale() const;

private:
    void initEdges();

    float world_scale{16.0f};
    std::array<Edge, MAP_BOX_EDGES_LEN> edges{};
};