我正在做cs61B的一个project,需要生成一个2D world,看到这篇文章,原文链接:https://blog.csdn.net/lindaicoding/article/details/119202956
里面有一个Directions类,direction包括上下左右,左上左下右上右下8个方向,我不知道这个Directions.getDirections().values()是怎么回事,我想知道这个getDirections() 和values的代码。
for(Point point : FloorPoints) {
for(Tuple direction : Directions.getDirections().values()) {
Point p = new Point(point.x + (int)direction.getFirst(), point.y + (int)direction.getSecond());
if(p.x < 0 || p.y < 0 || p.x >=WIDTH || p.y >= HEIGHT) continue;
if(world[p.x][p.y] == Tileset.FLOOR) continue;
if(world[p.x][p.y] == Tileset.WALL) continue;
WallPoints.add(new Point(p.x, p.y));
}