@Test public void testMapVisiting() { init(); Player player = new Player(); world.addEntity(player); world.gameLoop(1); assertEquals(World.getInstance().getTiles().getVisited(0, 0), false); MiniMap.updateVisited(player); assertEquals(World.getInstance().getTiles().getVisited(0, 0), true); }
public static void updateVisited(Player player) { if (player == null) { return; } int top = (int) Math.floor(player.getY() - Chunk.CHUNK_HEIGHT / 2); int left = (int) Math.floor(player.getX() - Chunk.CHUNK_WIDTH / 2); int right = (int) Math.floor(player.getX() + Chunk.CHUNK_WIDTH / 2); int bottom = (int) Math.floor(player.getY() + Chunk.CHUNK_HEIGHT / 2); WorldTiles tiles = World.getInstance().getTiles(); for (int x = left; x < right; x++) { for (int y = top; y < bottom; y++) { if (!tiles.test(x,y)) { continue; } if (isPointWithinRadius(x, y, (int)player.getX(), (int)player.getY(), player.getViewDistance())) { tiles.setVisited(x, y, true); } } } }
MiniMap { public static void updateVisited(Player player) { if (player == null) { return; } int top = (int) Math.floor(player.getY() - Chunk.CHUNK_HEIGHT / 2); int left = (int) Math.floor(player.getX() - Chunk.CHUNK_WIDTH / 2); int right = (int) Math.floor(player.getX() + Chunk.CHUNK_WIDTH / 2); int bottom = (int) Math.floor(player.getY() + Chunk.CHUNK_HEIGHT / 2); WorldTiles tiles = World.getInstance().getTiles(); for (int x = left; x < right; x++) { for (int y = top; y < bottom; y++) { if (!tiles.test(x,y)) { continue; } if (isPointWithinRadius(x, y, (int)player.getX(), (int)player.getY(), player.getViewDistance())) { tiles.setVisited(x, y, true); } } } } }
MiniMap { public static void updateVisited(Player player) { if (player == null) { return; } int top = (int) Math.floor(player.getY() - Chunk.CHUNK_HEIGHT / 2); int left = (int) Math.floor(player.getX() - Chunk.CHUNK_WIDTH / 2); int right = (int) Math.floor(player.getX() + Chunk.CHUNK_WIDTH / 2); int bottom = (int) Math.floor(player.getY() + Chunk.CHUNK_HEIGHT / 2); WorldTiles tiles = World.getInstance().getTiles(); for (int x = left; x < right; x++) { for (int y = top; y < bottom; y++) { if (!tiles.test(x,y)) { continue; } if (isPointWithinRadius(x, y, (int)player.getX(), (int)player.getY(), player.getViewDistance())) { tiles.setVisited(x, y, true); } } } } private  MiniMap(); }
MiniMap { public static void updateVisited(Player player) { if (player == null) { return; } int top = (int) Math.floor(player.getY() - Chunk.CHUNK_HEIGHT / 2); int left = (int) Math.floor(player.getX() - Chunk.CHUNK_WIDTH / 2); int right = (int) Math.floor(player.getX() + Chunk.CHUNK_WIDTH / 2); int bottom = (int) Math.floor(player.getY() + Chunk.CHUNK_HEIGHT / 2); WorldTiles tiles = World.getInstance().getTiles(); for (int x = left; x < right; x++) { for (int y = top; y < bottom; y++) { if (!tiles.test(x,y)) { continue; } if (isPointWithinRadius(x, y, (int)player.getX(), (int)player.getY(), player.getViewDistance())) { tiles.setVisited(x, y, true); } } } } private  MiniMap(); static void toggleVisibility(); static void setVisibility(boolean visibility); static boolean getVisibility(); static List<Entity> getMapEntities(List<Entity> allEntities); static void visitChunk(); static void updateVisited(Player player); }
MiniMap { public static void updateVisited(Player player) { if (player == null) { return; } int top = (int) Math.floor(player.getY() - Chunk.CHUNK_HEIGHT / 2); int left = (int) Math.floor(player.getX() - Chunk.CHUNK_WIDTH / 2); int right = (int) Math.floor(player.getX() + Chunk.CHUNK_WIDTH / 2); int bottom = (int) Math.floor(player.getY() + Chunk.CHUNK_HEIGHT / 2); WorldTiles tiles = World.getInstance().getTiles(); for (int x = left; x < right; x++) { for (int y = top; y < bottom; y++) { if (!tiles.test(x,y)) { continue; } if (isPointWithinRadius(x, y, (int)player.getX(), (int)player.getY(), player.getViewDistance())) { tiles.setVisited(x, y, true); } } } } private  MiniMap(); static void toggleVisibility(); static void setVisibility(boolean visibility); static boolean getVisibility(); static List<Entity> getMapEntities(List<Entity> allEntities); static void visitChunk(); static void updateVisited(Player player); static final int MAP_PADDING; }