20220626 - Générateur de terrain amélioré.

This commit is contained in:
mibi88 2022-06-26 12:02:27 +02:00
parent fa42f7e550
commit 6354e2152d
3 changed files with 9 additions and 6 deletions

View File

@ -2,4 +2,4 @@
# define WORLDGEN_SOIL 8 // Blocks (y) of soil.
# define WORLD_WIDTH 256 // World width.
# define WORLD_HEIGHT 128 // World height.
# define WORLD_HEIGHT 64 // World height.

View File

@ -60,12 +60,15 @@ int main(void) {
terrain[i] = 0;
}
srand(clock());
generateworld(terrain, WORLD_WIDTH, WORLD_HEIGHT, (int)rand() % 2, WORLD_HEIGHT - 20, WORLD_HEIGHT - 2, 0, 1);
generateworld(terrain, WORLD_WIDTH, WORLD_HEIGHT, (int)((rand() % ((WORLD_HEIGHT - 40) - (WORLD_HEIGHT - 60) + 1)) + WORLD_HEIGHT - 60), WORLD_HEIGHT - 60, WORLD_HEIGHT - 40, 0, 1);
srand(clock());
generateworld(terrain, WORLD_WIDTH, WORLD_HEIGHT, (int)rand() % 2, WORLD_HEIGHT - 35, WORLD_HEIGHT - 16, 3, 2);
generateworld(terrain, WORLD_WIDTH, WORLD_HEIGHT, (int)((rand() % ((WORLD_HEIGHT - 25) - (WORLD_HEIGHT - 40) + 1)) + WORLD_HEIGHT - 40), WORLD_HEIGHT - 40, WORLD_HEIGHT - 25, 3, 2);
game = 3;
}else if(game == 3){
dclear(C_WHITE);
if(key==KEY_RIGHT){
//
}
dupdate();
}
}

View File

@ -13,11 +13,11 @@ void generateworld(unsigned short terrain[], int w, int h, int genstart, int gen
if(a==0){
for(i=y;i!=h;i++){
srand(clock());
t = (int)rand() % 2;
t = (int)rand() % 11;
if(t==0){
terrain[i*w+x] = type;
}else if(t==1){
terrain[i*w+x] = someof;
}else{
terrain[i*w+x] = type;
}
}
}else if(a==1){