Takes in a 2d array of TETile objects and renders the 2d array to the screen, starting from xOffset and yOffset. If the array is an NxM array, then the element displayed at positions would be as follows, given in units of tiles. positions xOffset |xOffset+1|xOffset+2| .... |xOffset+
(TETile[][] world)
| 84 | * @param world the 2D TETile[][] array to render |
| 85 | */ |
| 86 | public void renderFrame(TETile[][] world) { |
| 87 | int numXTiles = world.length; |
| 88 | int numYTiles = world[0].length; |
| 89 | StdDraw.clear(new Color(0, 0, 0)); |
| 90 | for (int x = 0; x < numXTiles; x += 1) { |
| 91 | for (int y = 0; y < numYTiles; y += 1) { |
| 92 | if (world[x][y] == null) { |
| 93 | throw new IllegalArgumentException("Tile at position x=" + x + ", y=" + y |
| 94 | + " is null."); |
| 95 | } |
| 96 | world[x][y].draw(x + xOffset, y + yOffset); |
| 97 | } |
| 98 | } |
| 99 | StdDraw.show(); |
| 100 | } |
| 101 | } |