feat: add river biome

This commit is contained in:
2026-05-01 16:15:48 +08:00
parent d4d761b2aa
commit 9a4b814f4d
14 changed files with 126 additions and 22 deletions

View File

@@ -4,8 +4,9 @@ namespace Cubed {
constexpr int WORLD_SIZE_Y = 256;
constexpr int CHUCK_SIZE = 16;
constexpr int SEA_LEVEL = 64;
constexpr int MAX_BLOCK_NUM = 7;
constexpr int MAX_BLOCK_NUM = 8;
constexpr int MAX_UI_NUM = 1;
constexpr int MAX_BLOCK_STATUS = 1;
constexpr int MAX_BIOME_SUM = 4;

View File

@@ -12,7 +12,7 @@ constexpr float FOREST_FREQ = 1.2f;
constexpr float DESERT_FREQ = 1.2f;
constexpr float MOUNTAIN_FREQ = 2.0f;
enum class Biome { PLAIN = 0, FOREST, DESERT, MOUNTAIN, NONE };
enum class Biome { PLAIN = 0, FOREST, DESERT, MOUNTAIN, RIVER, NONE };
struct BiomeHeightRange {
int base_y;
@@ -26,10 +26,10 @@ struct BiomeNonAdjacent {
};
static inline const std::vector<BiomeNonAdjacent> NON_ADJACENT{
{{Biome::PLAIN, {Biome::NONE}, Biome::PLAIN},
{Biome::FOREST, {Biome::DESERT}, Biome::PLAIN},
{Biome::DESERT, {Biome::MOUNTAIN, Biome::FOREST}, Biome::PLAIN},
{Biome::MOUNTAIN, {Biome::DESERT}, Biome::PLAIN}}};
{{Biome::PLAIN, {Biome::DESERT}, Biome::RIVER},
{Biome::FOREST, {Biome::DESERT}, Biome::RIVER},
{Biome::DESERT, {Biome::MOUNTAIN, Biome::FOREST}, Biome::RIVER},
{Biome::MOUNTAIN, {Biome::DESERT, Biome::FOREST}, Biome::RIVER}}};
struct BaseBiomeParams {
Biome biome;
@@ -49,6 +49,8 @@ struct DesertParams : public BaseBiomeParams {};
struct MountainParams : public BaseBiomeParams {};
struct RiverParams : public BaseBiomeParams {};
std::string get_biome_str(Biome biome);
Biome get_biome_from_noise(float temp, float humid);
std::array<float, 3> get_noise_frequencies_for_biome(Biome biome);
@@ -61,5 +63,5 @@ PlainParams& plain_params();
ForestParams& forest_params();
DesertParams& desert_params();
MountainParams& mountain_params();
RiverParams& river_params();
} // namespace Cubed

View File

@@ -39,7 +39,7 @@ struct LookBlock {
};
constexpr std::array<std::string_view, MAX_BLOCK_NUM> BLOCK_REISTER{
"air", "grass_block", "dirt", "stone", "sand", "log", "leaf"};
"air", "grass_block", "dirt", "stone", "sand", "log", "leaf", "water"};
const std::array<bool, MAX_BLOCK_NUM> TRANSPARENT_MAP{
true, false, false, false, false, false, true};

View File

@@ -1,6 +1,7 @@
#pragma once
#include "Cubed/constants.hpp"
#include "Cubed/gameplay/biome.hpp"
#include "Cubed/tools/cubed_random.hpp"
#include <atomic>
@@ -49,6 +50,9 @@ private:
static inline std::atomic<bool> is_seed_change{false};
Chunk& m_chunk;
Random m_random;
std::array<Biome, 4> neighbor_biome{Biome::NONE, Biome::NONE, Biome::NONE,
Biome::NONE};
bool is_neighbor_river = false;
};
} // namespace Cubed