My program generated triangles automatically, however the arrangement of the triangles are random on JPanel. How can I plot the triangle in a grid order? Thanks.
EDITED:
for(int i = 0; i < 10; i++)
{
xCoord[0] = generator.nextInt(MAX_WIDTH);
yCoord[0] = generator.nextInt(MAX_HEIGHT);
xCoord[1] = (int) (xCoord[0] - xWidth);
xCoord[2] = (int) (xCoord[1] + (xWidth/2));
yCoord[1] = yCoord[0];
yCoord[2] = (int) (yCoord[1] - yHeight);
triangles.add( new Polygon(xCoord,yCoord, 3));
}
EDITED: OUTPUT DESIRED
How can I make the program generate many pattern but it MUST be in symmetrical form? e.g. left and right is symmetrical. I've tried to make Loop but so far it only generate 1 pattern. Help please :-(
*** *** OR ** ** OR *** *** etc (as long as it is symmetrical)
*** *** ** ** * *
* *