Hallo,
ich will ein zufälliges Polygon erstellen, also mit Zufallszahlen, was auch funktioniert,
aber mein Problem ist: Was muss ich machen, dass die Polygonseiten sich nicht kreuzen?
mfg
ich will ein zufälliges Polygon erstellen, also mit Zufallszahlen, was auch funktioniert,
aber mein Problem ist: Was muss ich machen, dass die Polygonseiten sich nicht kreuzen?
Code:
public void paint(Graphics g) {
int[] xPoints;
int[] yPoints;
int nPoints;
xPoints=new int[6];
yPoints=new int[6];
nPoints=6;
for(int i=0; i<6; i++) {
xPoints[i]= (int) (Math.random()*(100 - 0 + 1)) + 0;
yPoints[i]= (int) (Math.random()*(100 - 0 + 1)) + 0;
}
g.fillPolygon(xPoints, yPoints, nPoints);
}
mfg