Skip to content

Commit 88584a7

Browse files
reformat code
1 parent e913865 commit 88584a7

File tree

14 files changed

+62
-57
lines changed

14 files changed

+62
-57
lines changed

biome/Biome.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
//
44

55
#include <cmath>
6-
76
#include "Biome.h"
87

9-
Biome::Biome(std::string id, int x, int z, BiomeType *type) {
8+
using namespace std;
9+
10+
Biome::Biome(string id, int x, int z, BiomeType *type) {
1011
this->id = id;
1112
this->x = x;
1213
this->z = z;

biome/Biome.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ class Biome {
1616
std::string id;
1717
int x;
1818
int z;
19-
BiomeType* type;
19+
BiomeType *type;
20+
21+
Biome(std::string id, int x, int z, BiomeType *type);
2022

21-
Biome(std::string id, int x, int z, BiomeType* type);
2223
float distance_to(float x, float z);
2324
};
2425

block/Block.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ void Block::render() {
3434
else if (this->type == TREELEAVES) { texture.treeLeaves(); }
3535
else if (this->type == SNOW) { texture.snow(); }
3636
else if (this->type == WATER) { texture.water(); }
37-
else if (this->type == CLOUD ) { texture.cloud(); }
38-
else if (this->type == ORANGE ) { texture.orange(); }
39-
else if (this->type == LAWNGREEN ) { texture.lawngreen(); }
40-
else if (this->type == SAND ) { texture.sand(); }
41-
else if (this->type == ROCK ) { texture.rock(); }
37+
else if (this->type == CLOUD) { texture.cloud(); }
38+
else if (this->type == ORANGE) { texture.orange(); }
39+
else if (this->type == LAWNGREEN) { texture.lawngreen(); }
40+
else if (this->type == SAND) { texture.sand(); }
41+
else if (this->type == ROCK) { texture.rock(); }
4242
else { texture.ground(); }
4343

4444
glutSolidCube(1);
4545
glPopMatrix();
46-
}
46+
}

chunk/Chunk.cpp

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,14 @@ Chunk::Chunk(int chunk_x, int chunk_z, BiomeType *biome) {
126126

127127
if (k <= water_level) {
128128
this->blocks[i][water_level][j] = WATER;
129-
} else {
129+
} else {
130130

131131
this->blocks[i][k][j] = this->biome->ground;
132132

133133

134134
std::string key;
135135

136-
key = std::to_string(this->x+1) + "_" + std::to_string(this->z);
136+
key = std::to_string(this->x + 1) + "_" + std::to_string(this->z);
137137
if (worldPtr->chunks.count(key) > 0) {
138138
if (this->biome != worldPtr->chunks[key]->biome) {
139139
int random_number = rand() % 100;
@@ -151,7 +151,7 @@ Chunk::Chunk(int chunk_x, int chunk_z, BiomeType *biome) {
151151
}
152152

153153

154-
key = std::to_string(this->x) + "_" + std::to_string(this->z+1);
154+
key = std::to_string(this->x) + "_" + std::to_string(this->z + 1);
155155
if (worldPtr->chunks.count(key) > 0) {
156156
if (this->biome != worldPtr->chunks[key]->biome) {
157157
int random_number = rand() % 100;
@@ -169,7 +169,7 @@ Chunk::Chunk(int chunk_x, int chunk_z, BiomeType *biome) {
169169
}
170170

171171

172-
key = std::to_string(this->x-1) + "_" + std::to_string(this->z);
172+
key = std::to_string(this->x - 1) + "_" + std::to_string(this->z);
173173
if (worldPtr->chunks.count(key) > 0) {
174174
if (this->biome != worldPtr->chunks[key]->biome) {
175175
int random_number = rand() % 100;
@@ -187,7 +187,7 @@ Chunk::Chunk(int chunk_x, int chunk_z, BiomeType *biome) {
187187
}
188188

189189

190-
key = std::to_string(this->x) + "_" + std::to_string(this->z-1);
190+
key = std::to_string(this->x) + "_" + std::to_string(this->z - 1);
191191
if (worldPtr->chunks.count(key) > 0) {
192192
if (this->biome != worldPtr->chunks[key]->biome) {
193193
int random_number = rand() % 100;
@@ -205,12 +205,6 @@ Chunk::Chunk(int chunk_x, int chunk_z, BiomeType *biome) {
205205
}
206206

207207

208-
209-
210-
211-
212-
213-
214208
}
215209

216210
int snow_level_min = 23;
@@ -219,7 +213,7 @@ Chunk::Chunk(int chunk_x, int chunk_z, BiomeType *biome) {
219213

220214
//int snow = (rand() % (k+1) - snow_level_min) * snow_progress;
221215

222-
if(k > snow_level_min + 3 * sin(0.1 * (i + j))) {
216+
if (k > snow_level_min + 3 * sin(0.1 * (i + j))) {
223217
this->blocks[i][k][j] = SNOW;
224218
}
225219

chunk/Chunk.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,28 @@ class Chunk {
1717

1818
int x;
1919
int z;
20-
BiomeType* biome;
20+
BiomeType *biome;
2121

2222
int blocks[CHUNK_SIZE][CHUNK_HEIGHT][CHUNK_SIZE];
2323
int heights[CHUNK_SIZE][CHUNK_SIZE];
2424
//BiomeType biome;
2525

26-
Chunk(int chunk_x, int chunk_z, BiomeType* biome);
26+
Chunk(int chunk_x, int chunk_z, BiomeType *biome);
27+
2728
void render();
29+
2830
int random(int max);
31+
2932
int getBlock(int x, int y, int z);
33+
3034
int getHeight(int x, int z);
31-
float distance_to(Chunk* other);
35+
36+
float distance_to(Chunk *other);
37+
3238
float distance_to(float x, float z);
39+
3340
void generateStructures();
41+
3442
void removeHiddenBlocks();
3543
};
3644

keyboard/keyboard.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <cstdlib>
77
#include <iostream>
88
#import <GLUT/glut.h>
9+
910
using namespace std;
1011

1112

keyboard/keyboard.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "../main.h"
99

1010
void keydown(unsigned char key, int x, int y);
11+
1112
void keyup(unsigned char key, int x, int y);
1213

1314
#endif //PROJECT_KEYBOARD_H

light/Light.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "Light.h"
77

88
Light::Light() {
9-
for(int i = 0; i < 4; i++) {
9+
for (int i = 0; i < 4; i++) {
1010
this->diffuse[i] = 0.3;
1111
this->specular[i] = 1.3;
1212
this->ambient[i] = 0.65;

structures/Cactus.cpp

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,23 @@
99
Cactus::Cactus(int x, int y, int z, Chunk *chunk) {
1010

1111
int x_min = 0;
12-
int x_max = CHUNK_SIZE-1;
12+
int x_max = CHUNK_SIZE - 1;
1313
int z_min = 0;
14-
int z_max = CHUNK_SIZE-1;
14+
int z_max = CHUNK_SIZE - 1;
1515

1616

17-
if(x - 4 > x_min)x_min = x - 4;
18-
if(x + 4 < x_max)x_max = x + 4;
19-
if(z + 4 < z_max)z_max = z + 4;
20-
if(z + 4 < z_max)z_max = z + 4;
17+
if (x - 4 > x_min)x_min = x - 4;
18+
if (x + 4 < x_max)x_max = x + 4;
19+
if (z + 4 < z_max)z_max = z + 4;
20+
if (z + 4 < z_max)z_max = z + 4;
2121

2222

23-
24-
25-
if(x > 2 && x < 14 && z > 2 && z < 14) {
26-
int rand_dir = rand()%2;
23+
if (x > 2 && x < 14 && z > 2 && z < 14) {
24+
int rand_dir = rand() % 2;
2725

2826
chunk->blocks[x][y][z] = TREELEAVES;
29-
chunk->blocks[x][y+1][z] = TREELEAVES;
30-
chunk->blocks[x][y+2][z] = TREELEAVES;
31-
chunk->blocks[x][y+3][z] = TREELEAVES;
27+
chunk->blocks[x][y + 1][z] = TREELEAVES;
28+
chunk->blocks[x][y + 2][z] = TREELEAVES;
29+
chunk->blocks[x][y + 3][z] = TREELEAVES;
3230
}
3331
}

structures/Cloud.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "Cloud.h"
66
#include <random>
77
#include <iostream>
8+
89
using namespace std;
910

1011

@@ -17,7 +18,7 @@ Cloud::Cloud(int x, int y, int z, Chunk *chunk) {
1718
for (int i = -radius_cloud; i < radius_cloud; ++i) {
1819
for (int j = -radius_cloud; j < radius_cloud; ++j) {
1920
if (z + j < 16 && x + i < 16 && x + i > -1 && z + j > -1) {
20-
if (chunk->blocks[x + i][y][z + j] == AIR && z % 3 != 0 )
21+
if (chunk->blocks[x + i][y][z + j] == AIR && z % 3 != 0)
2122
chunk->blocks[x + i][y][z + j] = CLOUD;
2223
}
2324
}

0 commit comments

Comments
 (0)