1
0
mirror of https://github.com/p2r3/bareiron.git synced 2025-10-01 23:25:09 +02:00

add biomes

This commit is contained in:
p2r3
2025-08-20 22:35:26 +03:00
parent 08efb0b674
commit aeb0ad348f
4 changed files with 294 additions and 71 deletions

View File

@@ -6,6 +6,8 @@
#include "globals.h"
#define mod_abs(a, b) ((a % b + b) % b)
ssize_t recv_all (int client_fd, void *buf, size_t n, uint8_t require_first);
ssize_t send_all (int fd, const void *buf, size_t len);

View File

@@ -9,15 +9,21 @@
#define TERRAIN_BASE_HEIGHT 60
// Center point of cave generation
#define CAVE_BASE_DEPTH 24
// Size of every major biome in multiples of CHUNK_SIZE
// For best performance, should also be a power of 2
#define BIOME_SIZE 64
#define BIOME_RADIUS (BIOME_SIZE / 2)
typedef struct {
short x;
short z;
uint32_t hash;
uint8_t biome;
} ChunkAnchor;
uint32_t getChunkHash (short x, short z);
int getHeightAt (int rx, int rz, int _x, int _z, uint32_t chunk_hash);
uint8_t getChunkBiome (short x, short z);
int getHeightAt (int rx, int rz, int _x, int _z, uint32_t chunk_hash, uint8_t biome);
uint8_t getTerrainAt (int x, int y, int z, ChunkAnchor anchor);
uint8_t getBlockAt (int x, int y, int z);