/** * Initializes a hex in a specific direction from an origin hex */ private void initializeInDir(int x, int y, int dir) { initializeHex(Coords.xInDir(x, y, dir), Coords.yInDir(x, y, dir)); }
/** * Gets the hex in the specified direction from the specified starting * coordinates. Avoids calls to Coords.translated, and thus, object * construction. */ public IHex getHexInDir(int x, int y, int dir) { return getHex(Coords.xInDir(x, y, dir), Coords.yInDir(x, y, dir)); }
for (int dir = 0; dir < 6; dir++) { if (currHex.containsExit(dir)) { needsUpdate.add(new Coords(Coords.xInDir(x, y, dir), Coords.yInDir(x, y, dir)));
public final Coords translated(int dir, int distance) { int newx = xInDir(getX(), getY(), dir, distance); int newy = yInDir(getX(), getY(), dir, distance); return new Coords(newx, newy); }
private Coords selectNextGrid(int dir, Coords coords) { int x = Coords.xInDir(coords.getX(), coords.getY(), dir); int y = Coords.yInDir(coords.getX(), coords.getY(), dir); if (dir == E) { x++; } if (dir == W) { x--; } return new Coords(x, y); }
private void buildMetroCity(int maxX, int maxY) { int midX = maxX / 2; int midY = maxY / 2; cityPlan.add(new Coords(midX, midY)); // have the city hub be the mid point with all the hexes around it // cleared out for (int hex = 0; hex < 6; hex++) cityPlan.add(new Coords(Coords.xInDir(midX, midY, hex), Coords .yInDir(midX, midY, hex))); // first east west road Coords coords = new Coords(-1, midY / 2); buildStraightRoad(coords, E, 1); // second east west road coords = new Coords(-1, midY + (midY / 2)); buildStraightRoad(coords, E, 1); // First North South Road coords = new Coords(midX / 2, -1); buildStraightRoad(coords, S, 1); // second North South Road coords = new Coords(midX + (midX / 2), -1); buildStraightRoad(coords, S, 1); for (int dir = 0; dir < 8; dir++) { coords = new Coords(midX, midY); buildStraightRoad(coords, dir, 2); } }
ArrayList<Coords> smokeList = new ArrayList<Coords>(); smokeList.add(new Coords(Coords.xInDir(currentXCoord, currentYCoord, windDirection), Coords.yInDir(currentXCoord, currentYCoord, windDirection))); smokeList.add(new Coords(Coords.xInDir(currentXCoord, currentYCoord, (windDirection + 1) % 6), Coords.yInDir(currentXCoord, currentYCoord, (windDirection + 1) % 6))); smokeList.add(new Coords(Coords.xInDir(currentXCoord, currentYCoord, (windDirection + 5) % 6), Coords.yInDir(currentXCoord, currentYCoord, (windDirection + 5) % 6)));