Package civquest.util

Examples of civquest.util.Coordinate


    }
  } 

    public Coordinate[] getAbsFieldEdgeCoords(Coordinate coord) {
        Coordinate[] retValue = new Coordinate[4];
        Coordinate base = getAbsPaintCoord(coord);
        retValue[0] = new Coordinate(base.x, base.y);
        retValue[1] = base.add(cellWidth, 0);
        retValue[2] = base.add(cellWidth, cellHeight);
        retValue[3] = base.add(0, cellHeight);
        return retValue;
    }
View Full Code Here


    }
   
  } 


    public Coordinate getRandomCoordinate() {return new Coordinate(randomgen.nextInt(mapWidth),
                   randomgen.nextInt(mapHeight));}
View Full Code Here

   */
  public void updateDirtyFields(Buffer buffer, BufferManager bufferManager)
    throws InvalidImageException {
    MapData mapData = Game.getMapData();
   
    Coordinate fieldStart = buffer.getFieldRect().getTopLeftCorner();
    boolean[][] markedFields = buffer.getMarkedFields();
    Graphics2D graphics = buffer.getGraphics();
   
    for (int x = fieldStart.x; x < fieldStart.x + markedFields.length; x++) {
      for (int y = fieldStart.y; y < fieldStart.y + markedFields[0].length; y++) {
        if (markedFields[x - fieldStart.x][y - fieldStart.y]) {
          Coordinate unscrolledCoord = new Coordinate(x, y);
          Coordinate scrolledCoord = adjustArrayCoordToScrolling(unscrolledCoord);
//           paintField(new PaintInfo(scrolledCoord, unscrolledCoord),
//                  buffer);
        }       
      }   
    }   
View Full Code Here


  public FieldDistanceInfo[] getNeighborFieldDists(Field field) {
    FieldDistanceInfo[] retValue = new FieldDistanceInfo[8];

    Coordinate pos = field.getPosition();
    Coordinate[] neighborCoords = pos.getNeighborCoords();

    for (int n = 0;n < retValue.length; n++) {
      if (isOnMap(neighborCoords[n])) {
        int distance = 0;
        if (neighborCoords[n].x == pos.x || neighborCoords[n].y == pos.y) {
          distance = straightDistance;
        } else {
          distance = diagonalDistance;
        }
        retValue[n] = new FieldDistanceInfo(getField(neighborCoords[n]), distance);
      } else {
        Coordinate adjustedCoord = adjustToMapSize(neighborCoords[n]);
        if (adjustedCoord == null) {
          retValue[n] = null;
        } else {
          int distance = 0;
          if (adjustedCoord.y == pos.y) {
View Full Code Here

      MapData mapData = Game.getMapData();
      PaintInfo retInfo = new PaintInfo();
      retInfo.setCoord((Coordinate)(currCoord.clone()));
       
      Coordinate scrolledCoord = adjustArrayCoordToScrolling(currCoord);
      retInfo.setFieldPos(mapData.isOnMap(scrolledCoord) ? scrolledCoord : null);
       
      do {
        stepForward();
      } while (!finished && !mapData.isOnMap(adjustArrayCoordToScrolling(currCoord)));
View Full Code Here

   * |-------------------|
   * |-1, 1 | 0, 1 | 1, 1|
   * --------------------|
   */
  private Coordinate[] neighbours(Coordinate f){
      Coordinate a[] = new Coordinate[2];
      if ((f.x==0) || (f.y==0)){
    a[0] = new Coordinate(f.x+(f.y),f.y+(f.x));
    a[1] = new Coordinate(f.x-(f.y),f.y-(f.x));
      }
      else{
    a[0] = new Coordinate(f.x,0);
    a[1] = new Coordinate(0,f.y);
      }
      return a;
  }
View Full Code Here

      }
      return a;
  }

  private Coordinate[] mostLogicalCoordinate(Coordinate from){
      Coordinate r[] = new Coordinate[8];
      Coordinate b;
      Coordinate w[];
      r[0] = from;
      b = r[0];
      w = neighbours(r[0]);
      r[1] = w[0];
      r[2] = w[1];
      for (int i = 1; i<5; i++){
    w = neighbours(r[i]);
    if ((w[0].x==b.x) && (w[0].y==b.y))
        r[i+2] = w[1];
    else r[i+2] = w[0];
    if (i%2==0)
        b = r[1];
      }
      r[7] = new Coordinate(from.x*-1,from.y*-1);
      return r;
  }
View Full Code Here

        x=0
      if (from.y>to.y) y = 1; else
    if (from.y<to.y) y = -1; else
        y=0;
     
      Coordinate offset[] = mostLogicalCoordinate(new Coordinate(x,y))
      for (int i = 0; i<offset.length; i++)
    if (condition(new Coordinate(from.x-offset[i].x,from.y-offset[i].y), wmap)){
        wmap[from.x-offset[i].x][from.y-offset[i].y]=c;
        queue.add(new Coordinate(from.x-offset[i].x, from.y-offset[i].y));
    }      
  }
View Full Code Here

    }      
  }

  private Coordinate findParent(Coordinate from, int wmap[][]){
      int w = wmap[from.x][from.y];
      Coordinate c = null;
      for (int x = -1; x<2; x++)
    for (int y = -1; y<2; y++)
        if (map.isOnMap(from.x-x,from.y-y))
      if ((wmap[from.x-x][from.y-y]==w-1) && ((wmap[from.x-x][from.y-y]>0)))
          c = new Coordinate(from.x-x,from.y-y);
      return c;
  }
View Full Code Here

  private Vector<Coordinate> findPath(Coordinate from, Coordinate to){
      Vector<Coordinate> fpath = new Vector<Coordinate>();
      ArrayList<Coordinate> queue = new ArrayList<Coordinate>();
      int wmap[][] = new int[map.getArrayWidth()][map.getArrayHeight()];
      int c = 0;
      Coordinate workingNode = null;
      boolean end = false;
      if (from.equals(to)) return new Vector();
      wmap[from.x][from.y]=1;
      addToQueue(queue, from, to, wmap, 2);
      while (!(queue.isEmpty())){
View Full Code Here

TOP

Related Classes of civquest.util.Coordinate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.