0

我正在尝试使用 Gridworld 进行作业,这是作为 AP CS 课程的一部分推出的案例研究。任何熟悉 Gridworld 的人都可以告诉我 getDirectionToward(Location target) 方法的确切作用吗?我想我需要将它用于我需要能够判断一个对象是否面向另一个对象的分配,但文档没有帮助,说明它“返回最接近目标的指南针方向”。我不确定这甚至意味着什么。谢谢

4

1 回答 1

0

它返回最接近的指南针方向targetGridWorld中的方向系统(该类的页面 B1 Location)使用以下整数常量(IE,该方法将仅返回这些常量之一):

public static final int NORTH = 0;
public static final int EAST = 90;
public static final int SOUTH = 180;
public static final int WEST = 270;
public static final int NORTHEAST = 45;
public static final int SOUTHEAST = 135;
public static final int SOUTHWEST = 225;
public static final int NORTHWEST = 315;
于 2012-03-07T02:29:47.707 回答