szdytom b6656f5023
feat: Add biome-based terrain generation and Perlin noise implementation
- Introduced a new biome system with various biome types and properties.
- Implemented terrain generation using Perlin noise to create diverse landscapes.
- Added examples for basic tilemap generation and biome analysis.
- Created helper functions for displaying tiles and biomes in the console.
- Enhanced the TileMap class to support chunk-based tile management.
- Developed a PerlinNoise class for generating smooth noise patterns.
- Updated generation configuration to include climate parameters for biomes.
- Implemented error handling for out-of-bounds access in TileMap.

Signed-off-by: szdytom <szdytom@qq.com>
2025-08-01 14:28:36 +08:00

54 lines
1.3 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef ISTD_TILEMAP_TILEMAP_H
#define ISTD_TILEMAP_TILEMAP_H
#include "chunk.h"
#include <cstdint>
#include <vector>
namespace istd {
class TileMap {
private:
std::uint8_t size_; // Number of chunks in each dimension (n×n)
std::vector<std::vector<Chunk>> chunks_; // 2D array of chunks
public:
/**
* @brief Construct a TileMap with n×n chunks
* @param size Number of chunks in each dimension (max 100)
*/
explicit TileMap(std::uint8_t size);
/**
* @brief Get the size of the tilemap (number of chunks per side)
*/
std::uint8_t get_size() const {
return size_;
}
/**
* @brief Get a reference to a chunk at the given coordinates
* @param chunk_x X coordinate of the chunk
* @param chunk_y Y coordinate of the chunk
*/
Chunk &get_chunk(std::uint8_t chunk_x, std::uint8_t chunk_y);
const Chunk &get_chunk(std::uint8_t chunk_x, std::uint8_t chunk_y) const;
/**
* @brief Get a tile at the given position
* @param pos The position of the tile
*/
Tile &get_tile(const TilePos &pos);
const Tile &get_tile(const TilePos &pos) const;
/**
* @brief Set a tile at the given position
* @param pos The position of the tile
* @param tile The tile to set
*/
void set_tile(const TilePos &pos, const Tile &tile);
};
} // namespace istd
#endif