Domanda

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

È stato utile?

Soluzione

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;
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top