feat: add dirt and stone
BIN
assets/texture/block/dirt/back.png
Normal file
|
After Width: | Height: | Size: 482 B |
BIN
assets/texture/block/dirt/base.png
Normal file
|
After Width: | Height: | Size: 482 B |
BIN
assets/texture/block/dirt/front.png
Normal file
|
After Width: | Height: | Size: 482 B |
BIN
assets/texture/block/dirt/left.png
Normal file
|
After Width: | Height: | Size: 482 B |
BIN
assets/texture/block/dirt/right.png
Normal file
|
After Width: | Height: | Size: 482 B |
BIN
assets/texture/block/dirt/top.png
Normal file
|
After Width: | Height: | Size: 482 B |
|
Before Width: | Height: | Size: 569 B After Width: | Height: | Size: 563 B |
|
Before Width: | Height: | Size: 362 B After Width: | Height: | Size: 482 B |
|
Before Width: | Height: | Size: 569 B After Width: | Height: | Size: 563 B |
|
Before Width: | Height: | Size: 569 B After Width: | Height: | Size: 563 B |
|
Before Width: | Height: | Size: 569 B After Width: | Height: | Size: 563 B |
BIN
assets/texture/block/stone/back.png
Normal file
|
After Width: | Height: | Size: 382 B |
BIN
assets/texture/block/stone/base.png
Normal file
|
After Width: | Height: | Size: 382 B |
BIN
assets/texture/block/stone/front.png
Normal file
|
After Width: | Height: | Size: 382 B |
BIN
assets/texture/block/stone/left.png
Normal file
|
After Width: | Height: | Size: 382 B |
BIN
assets/texture/block/stone/right.png
Normal file
|
After Width: | Height: | Size: 382 B |
BIN
assets/texture/block/stone/top.png
Normal file
|
After Width: | Height: | Size: 382 B |
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
constexpr int WORLD_SIZE_Y = 256;
|
||||
constexpr int MAX_BLOCK_NUM = 2;
|
||||
constexpr int MAX_BLOCK_NUM = 4;
|
||||
constexpr int MAX_UI_NUM = 1;
|
||||
|
||||
constexpr int CHUCK_SIZE = 16;
|
||||
|
||||
@@ -216,7 +216,7 @@ void Chunk::init_chunk() {
|
||||
for (int x = 0; x < CHUCK_SIZE; x++) {
|
||||
for (int y = 0; y < 5; y++) {
|
||||
for (int z = 0; z < CHUCK_SIZE; z++) {
|
||||
m_blocks[get_index(x, y, z)] = 1;
|
||||
m_blocks[get_index(x, y, z)] = 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -233,10 +233,15 @@ void Chunk::init_chunk() {
|
||||
0.125f * PerlinNoise::noise(world_x * 0.04f, world_z * 0.04f, 0.5f);
|
||||
int y_max = height * noise;
|
||||
|
||||
for (int y = 5; y < y_max; y++) {
|
||||
for (int y = 5; y < y_max - 5; y++) {
|
||||
m_blocks[get_index(x, y, z)] = 3;
|
||||
}
|
||||
for (int y = y_max - 5; y < y_max - 1; y++) {
|
||||
m_blocks[get_index(x, y, z)] = 2;
|
||||
}
|
||||
for (int y = y_max - 1; y < y_max; y++) {
|
||||
m_blocks[get_index(x, y, z)] = 1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,13 @@
|
||||
std::unordered_map<unsigned, std::string> MapTable::id_to_name_map;
|
||||
std::unordered_map<size_t, unsigned> MapTable::name_to_id_map;
|
||||
|
||||
constexpr std::array<std::string, MAX_BLOCK_NUM> BLOCK_REISTER{
|
||||
"air",
|
||||
"grass_block",
|
||||
"dirt",
|
||||
"stone"
|
||||
};
|
||||
|
||||
|
||||
const std::string& MapTable::get_name_from_id(unsigned id) {
|
||||
auto it = id_to_name_map.find(id);
|
||||
@@ -17,13 +24,16 @@ const unsigned MapTable::get_id_from_name(const std::string& name) {
|
||||
CUBED_ASSERT_MSG(it != name_to_id_map.end(), "Name " + name + " is not exist");
|
||||
return it->second;
|
||||
}
|
||||
|
||||
void MapTable::init_map() {
|
||||
id_to_name_map.reserve(MAX_BLOCK_NUM);
|
||||
name_to_id_map.reserve(MAX_BLOCK_NUM);
|
||||
id_to_name_map[0] = "air";
|
||||
name_to_id_map[HASH::str("air")] = 0;
|
||||
id_to_name_map[1] = "grass_block";
|
||||
name_to_id_map[HASH::str("grass_block")] = 1;
|
||||
|
||||
for (int i = 0; i < MAX_BLOCK_NUM; i++) {
|
||||
id_to_name_map[i] = BLOCK_REISTER[i];
|
||||
name_to_id_map[HASH::str(BLOCK_REISTER[i])] = i;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||