diff --git a/src/GestionnaireNiveau.java b/src/GestionnaireNiveau.java index f58c757..7046ef0 100644 --- a/src/GestionnaireNiveau.java +++ b/src/GestionnaireNiveau.java @@ -20,27 +20,27 @@ public class GestionnaireNiveau { // Niveau 1 niveaux.add(new Niveau(1, new Color(112, 158, 251), - 8, 1 / 80.0, 70, 100, 500)); + 8, 1 / 30.0, 60, 0, 600)); // Niveau 2 niveaux.add(new Niveau(2, new Color(187, 138, 255), - 10, 1 / 60.0, 60, 100, 500)); + 10, 1 / 25.0, 55, 0, 600)); // Niveau 3 niveaux.add(new Niveau(3, new Color(255, 106, 132), - 11, 1 / 50.0, 55, 100, 500)); + 11, 1 / 20.0, 50, 0, 600)); // Niveau 4 niveaux.add(new Niveau(4, new Color(191, 255, 207), - 12, 1 / 40.0, 50, 100, 500)); + 12, 1 / 17.0, 47, 0, 600)); // Niveau 5 niveaux.add(new Niveau(5, new Color(251, 233, 144), - 13, 1 / 35.0, 45, 100, 500)); + 13, 1 / 15.0, 45, 100, 600)); } public void mettreAJour() { diff --git a/src/Ligne.java b/src/Ligne.java index 77d0e68..6a9cbd0 100644 --- a/src/Ligne.java +++ b/src/Ligne.java @@ -78,7 +78,7 @@ public class Ligne extends ObjetGraphique { double limiteBas = gestionnaireNiveau.getLimiteBas(); double hauteur = limiteBas - limiteHaut; - double bruit = noiseGenerator.noise(noisePos); + double bruit = noiseGenerator.noise(noisePos, 1); double normalise = (bruit + 1) / 2; return limiteBas - normalise * hauteur; diff --git a/src/NoiseGenerator.java b/src/NoiseGenerator.java index 650f43c..357c134 100644 --- a/src/NoiseGenerator.java +++ b/src/NoiseGenerator.java @@ -109,11 +109,32 @@ public class NoiseGenerator { return value / initialSize; } + /** + * Noise 1D avec nombre d'octaves controle. + * 1 octave = lisse, utilise tout le range [-1, 1]. + * Plus d'octaves = plus de detail/jitter, mais converge vers 0. + */ + public double noise(double x, int octaves) { + double value = 0.0; + double size = default_size; + double weightSum = 0; + int count = 0; + + while (size >= 1 && count < octaves) { + value += smoothNoise((x / size), (x / size), (x / size)) * size; + weightSum += size; + size /= 2.0; + count++; + } + + return value / weightSum; + } + public double smoothNoise(double x, double y, double z) { // Offset each coordinate by the seed value x += this.seed; y += this.seed; - x += this.seed; + z += this.seed; int X = (int) Math.floor(x) & 255; // FIND UNIT CUBE THAT int Y = (int) Math.floor(y) & 255; // CONTAINS POINT.