Name: übermench 2011-12-26 2:30
any good tutorials about procedural terrain generating /prog/? I am currently particularly interested how rivers can be generating, how do the affect the terrain.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define _(i,j) d[(i)+(w+2)*(j)]
#define __(i) for(int i=0;i<w;i++)
int main(){
int w, arr[]={620757024, 621552898, 620766464, 623650064,
622077186, 622601474, 624174360, 624698660};
scanf("%d",&w);
short *dat=(short*)malloc((w+2)*(w+2)*2), *d = dat+w+1;
srand(time(0));
__(i)__(j)_(i,j) = (j&&j+1-w?0:5) | (i&&i+1-w?0:10) | rand()%4&(w-1-j?w-1-i?15:14:13)
| (j?i?15:11:7) & (_(i-1,j)&1 | _(i,j-1)&2)<<2;
__(i)__(j)_(i,j) = *(((short*)arr)+_(i,j)),*(int*)(d+i*(w+2)-2) = 655373;
fwrite(&(d[-1]=-257),2,w*(w+2)-1,fopen("o.txt", "wb"));
return 0;
}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
||||||||||||||||||||||||||||||||||||