MCPcopy Create free account
hub / github.com/Berkeley-CS61B/skeleton-sp23 / renderFrame

Method renderFrame

lab12/src/tileengine/TERenderer.java:86–100  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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}

Callers 3

mainMethod · 0.95
mainMethod · 0.95
mainMethod · 0.95

Calls 2

clearMethod · 0.65
drawMethod · 0.45

Tested by

no test coverage detected