我现在有一个数组,
static int[][] map = new int[WIDTH][HEIGHT];
此代码在地图上放置图块:
for (int y = 18; y < HEIGHT; y++) {
for (int x = 0; x < WIDTH; x++) {
map[x][y] = STONE;
}
}
for (int y = 18; y < 19; y++) {
for (int x = 0; x < WIDTH; x++) {
map[x][y] = GRASS;
}
}
for (int y = 19; y < 20; y++) {
for (int x = 0; x < WIDTH; x++) {
map[x][y] = DIRT;
}
}
这是我渲染它们的方式:
for (int x = 0; x < WIDTH; x++) {
for (int y = 0; y < HEIGHT; y++) {
switch (map[x][y]) {
case CLEAR:
air.draw(x * TILE_SIZE, y * TILE_SIZE, TILE_SIZE, TILE_SIZE);
break;
case STONE:
stone.draw(x * TILE_SIZE, y * TILE_SIZE, TILE_SIZE, TILE_SIZE);
break;
case GRASS:
grass.draw(x * TILE_SIZE, y * TILE_SIZE, TILE_SIZE, TILE_SIZE);
break;
case DIRT:
dirt.draw(x * TILE_SIZE, y * TILE_SIZE, TILE_SIZE, TILE_SIZE);
break;
}
}
}
如何转换此代码以用二维数组列表替换数组映射,以便我可以像我的世界一样删除这些图块?