add block rotate

This commit is contained in:
lllzebralll
2022-11-19 23:05:33 +03:00
parent d2416946d9
commit 900e4ae098
11 changed files with 233 additions and 73 deletions
+1
View File
@@ -19,6 +19,7 @@ public:
bool obstacle = true;
bool selectable = true;
bool breakable = true;
bool rotatable = false;
float hitboxScale = 1;
float hitboxY = 1;
+1 -1
View File
@@ -6,7 +6,7 @@
#define CHUNK_W 16
#define CHUNK_H 256
#define CHUNK_D 16
#define CHUNK_VOL (CHUNK_W * CHUNK_H * CHUNK_D)
#define CHUNK_VOL (CHUNK_W * CHUNK_H * CHUNK_D * 2)
#define CHUNK_MODIFIED 0x1
#define CHUNK_READY 0x2
+2 -1
View File
@@ -123,7 +123,7 @@ Chunk* Chunks::getChunk(int x, int z){
return chunks[z * w + x];
}
void Chunks::set(int x, int y, int z, int id){
void Chunks::set(int x, int y, int z, int id, uint8_t states){
x -= ox * CHUNK_W;
z -= oz * CHUNK_D;
int cx = x / CHUNK_W;
@@ -140,6 +140,7 @@ void Chunks::set(int x, int y, int z, int id){
int lx = x - cx * CHUNK_W;
int lz = z - cz * CHUNK_D;
chunk->voxels[(y * CHUNK_D + lz) * CHUNK_W + lx].id = id;
chunk->voxels[(y * CHUNK_D + lz) * CHUNK_W + lx].states = states;
chunk->setUnsaved(true);
chunk->setModified(true);
+1 -1
View File
@@ -34,7 +34,7 @@ public:
voxel* get(int x, int y, int z);
unsigned short getLight(int x, int y, int z);
unsigned char getLight(int x, int y, int z, int channel);
void set(int x, int y, int z, int id);
void set(int x, int y, int z, int id, uint8_t states);
voxel* rayCast(vec3 start, vec3 dir, float maxLength, vec3& end, vec3& norm, vec3& iend);
bool isObstacle(int x, int y, int z);
+1
View File
@@ -151,6 +151,7 @@ void WorldGenerator::generate(voxel* voxels, int cx, int cz, int seed){
id = BLOCK_FLOWER;
}
voxels[(y * CHUNK_D + z) * CHUNK_W + x].id = id;
voxels[(y * CHUNK_D + z) * CHUNK_W + x].states = 0x32;
}
}
}
+1
View File
@@ -5,6 +5,7 @@
struct voxel {
uint8_t id;
uint8_t states;
};
#endif /* VOXELS_VOXEL_H_ */