Exemple #1
0
 public static boolean directionPassable(Directions d, Tile t) {
   final int[][] flags = Walking.getCollisionFlags(Game.getPlane());
   final Tile offset =
       Walking.getCollisionOffset(Game.getPlane()).derive(Game.getBaseX(), Game.getBaseY());
   int toCheckFlag = flags[t.getX() - offset.getX()][t.getY() - offset.getY()];
   return ((toCheckFlag & ~d.getBlockFlag()) == toCheckFlag);
 }
Exemple #2
0
  public static Tile getClosestOnMap(Tile tile) {
    if (tile.isOnMap()) {
      return tile;
    }

    final Tile location = Players.getLocal().getLocation();
    tile = tile.derive(-location.getX(), -location.getY());
    final double angle = Math.atan2(tile.getY(), tile.getX());
    return new Tile(
        location.getX() + (int) (16d * Math.cos(angle)),
        location.getY() + (int) (16d * Math.sin(angle)),
        tile.getPlane());
  }
Exemple #3
0
 public void setCameraRelativeTo(final Locatable reference) {
   final Tile playerTile = Players.getLocal().getLocation();
   final Tile referenceTile = reference.getLocation();
   if (playerTile.getX() < referenceTile.getX()) {
     Camera.setAngle(Random.nextInt(250, 270));
   } else if (playerTile.getX() > referenceTile.getX()) {
     Camera.setAngle(Random.nextInt(80, 100));
   } else if (playerTile.getY() > referenceTile.getY()) {
     Camera.setAngle(Random.nextInt(170, 180));
   } else if (playerTile.getY() < referenceTile.getY()) {
     Camera.setAngle(Random.nextInt(350, 360));
   }
 }