bettola/srv/game/world.h
Ritchie Cunningham 744c41b8ce [Add] Terrain collision and gravity.
Physics and collision system to make players interact with the generated
terraine without falling through the world like lemmings.

It uses a shared bilinear interpolation function for terrain height for
smooth and consistant height queries on the client and server.
2025-09-16 22:13:15 +01:00

30 lines
600 B
C++

#pragma once
#include <map>
#include "bettola/noise/fast_noise_lite.h"
#include "bettola/game/chunk.h"
struct ChunkPos {
int x, z;
bool operator<(const ChunkPos& other) const {
if(x < other.x) return true;
if(x > other.x) return false;
return z < other.z;
}
};
class World {
public:
World(void);
BettolaLib::Game::Chunk& get_chunk(int x, int z);
float get_height(float world_x, float world_z);
private:
void _generate_chunk(BettolaLib::Game::Chunk& chunk, int chunk_x, int chunk_z);
FastNoiseLite m_noise;
std::map<ChunkPos, BettolaLib::Game::Chunk> m_chunks;
};