szdytom 6be8869568
fix: biome demo
Signed-off-by: szdytom <szdytom@qq.com>
2025-08-01 21:37:23 +08:00

72 lines
1.6 KiB
C++

#ifndef TILEMAP_BIOME_H
#define TILEMAP_BIOME_H
#include <cstdint>
#include <string_view>
namespace istd {
// Biome types based on temperature and humidity
enum class BiomeType : std::uint8_t {
SnowyPeeks = 0, // Cold & Dry
SnowyPlains = 1, // Cold & Moderate
FrozenOcean = 2, // Cold & Wet
Plains = 3, // Temperate & Dry
Forest = 4, // Temperate & Moderate
Ocean = 5, // Temperate & Wet
Desert = 6, // Hot & Dry
Savanna = 7, // Hot & Moderate
LukeOcean = 8, // Hot & Wet
};
enum class BiomeTemperature : std::uint8_t {
Cold = 0,
Temperate = 1,
Hot = 2,
};
enum class BiomeHumidity : std::uint8_t {
Dry = 0,
Moderate = 1,
Wet = 2,
};
// Biome properties for terrain generation
struct BiomeProperties {
// Biome name for debugging
std::string_view name;
// Base terrain ratios (0.0 - 1.0)
double water_ratio;
double ice_ratio;
double sand_ratio;
double land_ratio;
// Noise parameters for base terrain
int base_octaves = 3;
double base_persistence = 0.5;
};
// Get biome properties for terrain generation
const BiomeProperties &get_biome_properties(BiomeType biome);
// Determine biome type based on temperature and humidity
BiomeType determine_biome(double temperature, double humidity);
// Sub-chunk position within a chunk (4x4 grid of 16x16 sub-chunks)
struct SubChunkPos {
std::uint8_t sub_x; // 0-3
std::uint8_t sub_y; // 0-3
constexpr SubChunkPos(std::uint8_t x, std::uint8_t y): sub_x(x), sub_y(y) {}
};
// Get the starting tile coordinates for a sub-chunk
std::pair<std::uint8_t, std::uint8_t> subchunk_to_tile_start(
const SubChunkPos &pos
);
} // namespace istd
#endif