문제

I am trying to do an assignment using Gridworld, a case study put out as part of the AP CS curriculum. Could anyone familiar with Gridworld tell me what the method getDirectionToward(Location target) does exactly? I think I need to use it for an assignment in which I need to be able to tell if one object is facing another, but the documentation isnt helpful, stating that it "returns the closest compass direction toward target." I'm not exactly sure what that even means. Thanks

도움이 되었습니까?

해결책

It returns the closest compass direction towards the target. The direction system in GridWorld (Page B1 for the Location class) works with the following integer constants (IE, the method will only return one of these constants):

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;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top