so i have a cube object that i made as a base for a wall but the wall is a bunch of different shapes, so i was wondering if i could stick them end to end without doing it manually as there's two of each shape in the mapped area.


1 2 3 4 5 6 7 8 9 10 11 12 | public void wall( int x, int y) { World.addObject( new cube(), x, y); y= y-cube.getHeight(); World.addObject( new tirangle(), x, y); y= y-triangle.getHeight(); World.addObject( new circle(), x, y); } |
1 2 3 4 5 6 7 8 9 10 11 | public void wall( int x, int y) { Cube cube = new Cube(); getWorld().addObject(cube, x, y); y-=cube.getImage().getHeight(); Triangle triangle = new Triangle(); getWorld().addObject(triangle, x, y); y-=triangle.getImage().getHeight(); Circle circle = new Circle(); getWorld().addObject(circle, x, y); } |
1 2 | private int [] xLocations = { 491 , 507 , 523 , 539 , 555 , 571 ,... private int [] yLocations = { 402 , 402 , 402 , 402 , 402 , 402 ,... |
1 2 3 4 5 6 7 8 9 10 11 | private void makeWalls() { int q = 0 ; while (q < 75 ) { addObject( new Wall(),xLocations[q],yLocations[q]); q = q + 1 ; } |
1 2 3 4 5 6 7 8 9 | private int [][] map ={ { 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 }, { 1 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 1 }, { 1 , 0 , 1 , 0 , 0 , 0 , 1 , 0 , 1 }, { 1 , 0 , 1 , 1 , 1 , 1 , 1 , 0 , 1 }, { 1 , 0 , 1 , 0 , 0 , 0 , 1 , 0 , 1 }, { 1 , 0 , 1 , 0 , 1 , 0 , 1 , 0 , 1 }, { 1 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 1 }, { 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 }}; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | private int [][] map = { { 9 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 3 }, { 8 , 0 , 0 , 0 , 10 , 0 , 0 , 0 , 2 }, { 8 , 0 , 15 , 0 , 14 , 0 , 15 , 0 , 2 }, { 8 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 2 }, { 8 , 0 , 15 , 0 , 11 , 0 , 15 , 0 , 2 }, { 8 , 0 , 0 , 0 , 10 , 0 , 0 , 0 , 2 }, { 12 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 6 } }; // with the following in a method for ( int y= 0 ; y<map.length; y++) for ( int x= 0 ; x<map[].length; x++) { Actor actor = null ; switch (map[y][x]) { case 0 : break ; case 1 : actor = new Wall( "top" ); break ; case 2 : actor = new Wall( "right" ); break ; case 3 : actor = new Wall( "top-right" ); break ; // etc. } if (actor != null ) addObject(actor, 8 +x* 16 , 8 +y* 16 ); } |