Issue 1 fixed.

master
Quentin BAZIN 2013-04-30 19:36:41 +02:00
parent f6fc91c5ec
commit 1488d9b71c
7 changed files with 38 additions and 19 deletions

20
Notes
View File

@ -1,6 +1,14 @@
Issues:
- Bug when adding cubes from a chunk to the border of another one.
- Chunks in diagonal will not be tested for cube selection.
1: io Bug when adding cubes from a chunk to the border of another one.
2: ix Chunks in diagonal will not be tested for cube selection.
3: nixs Sometimes, the distance for cube selection is too limited.
Legend for issues:
n: New
i: Important
o: Fixed
x: Not fixed
s: With screenshot
Cubes:
0: Nothing
@ -10,6 +18,14 @@ Cubes:
4: Grass
Faces:
0: y + 1 |
1: x + 1 |
2: x - 1 |
3: y - 1 |
4: z + 1 | Top
5: z - 1 | Bottom
SurroundingChunks:
0: FL
1: FR
2: BL

1
TODO
View File

@ -1,3 +1,4 @@
- Fix important issues
- Physics
- Pause menu
- Main menu

View File

@ -38,6 +38,7 @@ class Chunk {
int y() const { return m_y; }
int z() const { return m_z; }
void putCube(int x, int y, int z, int type) { m_cubes[CUBE_POS(x, y, z)] = new Cube(x, y, z, type); }
std::unordered_map<int, Cube*> cubes() const { return m_cubes; }
Chunk **surroundingChunks() const { return m_surroundingChunks; }

View File

@ -33,4 +33,9 @@
#define CHUNK_DEPTH 8
#define CHUNK_HEIGHT 8
#define MAP_POS(x, y, z) ((x) + ((y) * Game::mapWidth) + ((z) * Game::mapWidth * Game::mapDepth))
#define _MAP_POS(x, y, z) ((x) + ((y) * m_width) + ((z) * m_width * m_depth))
#define CHUNK_POS(x, y, z) ((x) + ((y) * (m_width >> 3)) + ((z) * (m_width >> 3) * (m_depth >> 3)))
#define CUBE_POS(x, y, z) (((x) - m_x) + (((y) - m_y) * CHUNK_WIDTH) + (((z) - m_z) * CHUNK_WIDTH * CHUNK_HEIGHT))
#endif // CONFIG_H

View File

@ -20,11 +20,6 @@
#ifndef MAP_H
#define MAP_H
#define MAP_POS(x, y, z) ((x) + ((y) * Game::mapWidth) + ((z) * Game::mapWidth * Game::mapDepth))
#define _MAP_POS(x, y, z) ((x) + ((y) * m_width) + ((z) * m_width * m_depth))
#define CHUNK_POS(x, y, z) ((x) + ((y) * (m_width >> 3)) + ((z) * (m_width >> 3) * (m_depth >> 3)))
#define CUBE_POS(x, y, z) (((x) - m_x) + (((y) - m_y) * CHUNK_WIDTH) + (((z) - m_z) * CHUNK_WIDTH * CHUNK_HEIGHT))
typedef struct {
float x;
float y;

BIN
issues/issue3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 KiB

View File

@ -98,49 +98,50 @@ void Chunk::addCube(Cube *selectedCube, int type) {
int y = selectedCube->y();
int z = selectedCube->z();
/*if(x == 0) {
m_surroundingChunks[0]->addCube(m_surroundingChunks[0]->getCube(CHUNK_WIDTH - 1, y, z), type);
return;
}*/
if((selectedCube == NULL) || (selectedCube->selectedFace() == -1)) {
if(selectedCube->selectedFace() == -1) {
m_cubes[CUBE_POS(x, y, z)] = selectedCube;
return;
}
else if(selectedCube->selectedFace() == 0) {
if((MAP_POS(x, y + 1, z) >= 0) && (MAP_POS(x, y + 1, z) < Game::map->width() * Game::map->depth() * Game::map->height())) {
Game::map->map()[MAP_POS(x, y + 1, z)] = type;
m_cubes[CUBE_POS(x, y + 1, z)] = new Cube(x, y + 1, z, type);
if(y + 1 - m_y < CHUNK_DEPTH) m_cubes[CUBE_POS(x, y + 1, z)] = new Cube(x, y + 1, z, type);
else if(m_surroundingChunks[3] != NULL) m_surroundingChunks[3]->putCube(x, y + 1, z, type);
}
}
else if(selectedCube->selectedFace() == 1) {
if((MAP_POS(x + 1, y, z) >= 0) && (MAP_POS(x + 1, y, z) < Game::map->width() * Game::map->depth() * Game::map->height())) {
Game::map->map()[MAP_POS(x + 1, y, z)] = type;
m_cubes[CUBE_POS(x + 1, y, z)] = new Cube(x + 1, y, z, type);
if(x + 1 - m_x < CHUNK_WIDTH) m_cubes[CUBE_POS(x + 1, y, z)] = new Cube(x + 1, y, z, type);
else if(m_surroundingChunks[1] != NULL) m_surroundingChunks[1]->putCube(x + 1, y, z, type);
}
}
else if(selectedCube->selectedFace() == 2) {
if((MAP_POS(x - 1, y, z) >= 0) && (MAP_POS(x - 1, y, z) < Game::map->width() * Game::map->depth() * Game::map->height())) {
Game::map->map()[MAP_POS(x - 1, y, z)] = type;
m_cubes[CUBE_POS(x - 1, y, z)] = new Cube(x - 1, y, z, type);
if(x - 1 - m_x >= 0) m_cubes[CUBE_POS(x - 1, y, z)] = new Cube(x - 1, y, z, type);
else if(m_surroundingChunks[0] != NULL) m_surroundingChunks[0]->putCube(x - 1, y, z, type);
}
}
else if(selectedCube->selectedFace() == 3) {
if((MAP_POS(x, y - 1, z) >= 0) && (MAP_POS(x, y - 1, z) < Game::map->width() * Game::map->depth() * Game::map->height())) {
Game::map->map()[MAP_POS(x, y - 1, z)] = type;
m_cubes[CUBE_POS(x, y - 1, z)] = new Cube(x, y - 1, z, type);
if(y - 1 - m_y >= 0) m_cubes[CUBE_POS(x, y - 1, z)] = new Cube(x, y - 1, z, type);
else if(m_surroundingChunks[2] != NULL) m_surroundingChunks[2]->putCube(x, y - 1, z, type);
}
}
else if(selectedCube->selectedFace() == 4) {
if((MAP_POS(x, y, z + 1) >= 0) && (MAP_POS(x, y, z + 1) < Game::map->width() * Game::map->depth() * Game::map->height())) {
Game::map->map()[MAP_POS(x, y, z + 1)] = type;
m_cubes[CUBE_POS(x, y, z + 1)] = new Cube(x, y, z + 1, type);
if(z + 1 - m_z < CHUNK_HEIGHT) m_cubes[CUBE_POS(x, y, z + 1)] = new Cube(x, y, z + 1, type);
else if(m_surroundingChunks[4] != NULL) m_surroundingChunks[4]->putCube(x, y, z + 1, type);
}
}
else if(selectedCube->selectedFace() == 5) {
if((MAP_POS(x, y, z - 1) >= 0) && (MAP_POS(x, y, z - 1) < Game::map->width() * Game::map->depth() * Game::map->height())) {
Game::map->map()[MAP_POS(x, y, z - 1)] = type;
m_cubes[CUBE_POS(x, y, z - 1)] = new Cube(x, y, z - 1, type);
if(z - 1 - m_z >= 0) m_cubes[CUBE_POS(x, y, z - 1)] = new Cube(x, y, z - 1, type);
else if(m_surroundingChunks[5] != NULL) m_surroundingChunks[5]->putCube(x, y, z - 1, type);
}
}