Builder_for_CG/src/worldgen.h

38 lines
673 B
C

/*
0 - Nothing.
1 - Soil.
2 - Stone.
3 - Coal.
4 - Steel.
5 - Wood.
*/
void generateworld(unsigned short terrain[], int w, int h, int genstart, int genmin, int genmax, int someof, int type) {
int x = 0, y = genstart, n, i, a, t;
for(x=0;x!=w;x++){
//srand(clock());
a = (int)rand() % 2;
if(a==0){
for(i=y;i!=h;i++){
//srand(clock());
t = (int)rand() % 11;
if(t==0){
terrain[i*w+x] = someof;
}else{
terrain[i*w+x] = type;
}
}
}else if(a==1){
for(i=y;i!=h;i++){
terrain[i*w+x] = type;
}
}
//srand(clock());
n = (int)rand() % 2;
if(n==0 && y<genmax){
y++;
}else if(n==1 && y>genmin){
y--;
}
}
}