Witam!
Chcę stworzyć kosmiczne wormsy, ale mam pewien problem- nie za bardzo mam pomysł na stworzenie losowej wielkości i miejsca usytuowania planety/planet. Chciał bym mieć na ekranie 2-3 koła(planety).
Kod który teraz mam odpowiada za randomową generacje powierzchni.
private void GenerateTerrainContour()
{
terrainContour = new int[screenWidth];
float offset = screenHeight / 2;
float peakheight = 100;
float flatness = 50;
for (int x = 0; x < screenWidth; x++)
{
double height = peakheight * Math.Sin((float)x / flatness)+offset;
terrainContour[x] = (int)height;
}
}
oraz
private void GenerateTerrainContour()
{
terrainContour = new int[screenWidth];
double rand1 = randomizer.NextDouble() + 1;
double rand2 = randomizer.NextDouble() + 2;
double rand3 = randomizer.NextDouble() + 3;
float offset = screenHeight / 2;
float peakheight = 100;
float flatness = 70;
for (int x = 0; x < screenWidth; x++)
{
double height = peakheight / rand1 * Math.Sin((float)x / flatness * rand1 + rand1);
height += peakheight / rand2 * Math.Sin((float)x / flatness * rand2 + rand2);
height += peakheight / rand3 * Math.Sin((float)x / flatness * rand3 + rand3);
height += offset;
terrainContour[x] = (int)height;
}
}
Prosił bym o konkretne sugestie rozwiązujące mój problem.
Myślę teraz o rozwiązanie tego problemu poprzez zastosowanie prymitywu.