1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| void genere(int tab[][TAILLE], int x, int y, int distance)
{
if(x+distance>=TAILLE || x-distance<0 || y+distance>=TAILLE || y-distance<0)
distance--;
int a = tab[y-distance][x-distance], b = tab[y-distance][x+distance], c = tab[y+distance][x+distance], d = tab[y+distance][x-distance],
e = (a+b+c+d)/4 + random(0, distance);
tab[y][x] = e;
tab[y-distance][x] = (a+b+e)/3 + random(0, distance); // G
tab[y][x+distance] = (b+d+e)/3 + random(0, distance); // H
tab[y+distance][x] = (c+d+e)/3 + random(0, distance); // I
tab[y][x-distance] = (a+c+e)/3 + random(0, distance); // F
if(distance > 1)
{
genere(tab, x-distance/2, y-distance/2, distance/2);
genere(tab, x+distance/2, y-distance/2, distance/2);
genere(tab, x+distance/2, y+distance/2, distance/2);
genere(tab, x-distance/2, y+distance/2, distance/2);
}
} |
Partager