Package transientlibs.rlforj.math

Examples of transientlibs.rlforj.math.Point2I


       
        Iterator<Point2I> it = path.iterator();
        it.next();
       
        while (it.hasNext()) {
            Point2I coords = it.next();
            onX = fromScreenX + ((coords.x - fromCoords.getIntX())*Terrain.tileWidth);
            onY = fromScreenY + ((coords.y - fromCoords.getIntY())*Terrain.tileHeight);
            if (Detonator.INSTANCE.tileMovementCalculator.isShootingObstacle (coords.x, coords.y)) {
            redTile.draw(onX, onY);
            } else{
View Full Code Here


        clearSight();
        //visited = new boolean[w][h];
    }

    public void mark(int x, int y, char c) {
        marks.put(new Point2I(x, y), c);
    }
View Full Code Here

    /**
     * Debug output of what tiles are visible
     */
    public void print(int ox, int oy) {
        Point2I p = new Point2I(0, 0);
        for (int j = 0; j < h; j++) {
            for (int i = 0; i < w; i++) {
                p.x = i;
                p.y = j;
                Character c = marks.get(p);
View Full Code Here

            return;
        }

        int lastx = path.get(0).x, lasty = path.get(0).y;
        for (int i = 1; i < path.size(); i++) {
            Point2I p = path.get(i);
            int x = p.x, y = p.y;
            if (x != lastx) {
                if (y != lasty) {
                    b.mark(x, y, ((x - lastx) * (y - lasty) > 0) ? '\\' : '/');
                } else {
View Full Code Here

    marks.clear();
    visited = new boolean[w][h];
  }

  public void mark(int x, int y, char c) {
    marks.put(new Point2I(x, y), c);
  }
View Full Code Here

  {
    visited[x][y]=true;
  }
 
  public void print(int ox, int oy) {
    Point2I p=new Point2I(0, 0);
    for(int j=0; j<h; j++) {
      for(int i=0; i<w; i++) {
        p.x=i; p.y=j;
        Character c=marks.get(p);
        if(c!=null) System.out.print(c);
View Full Code Here

    BresenhamLine.plot(startX, startY, x1, y1, px, py);

    boolean los=false;
    for(int i=0; i<len; i++) {
      if(calculateProject){
        path.add(new Point2I(px[i], py[i]));
      }
      if(px[i]==x1 && py[i]==y1) {
        los=true;
        break;
      }
      if(b.isObstacle(px[i], py[i]))
        break;
    }
    // Direct path couldnt find LOS so try alternate path
    if(!los && symmetricEnabled) {
      int[] px1=null, py1=null;
      // allocate space for alternate path
      px1=new int[len]; py1=new int[len];
      // finish to start path.
      BresenhamLine.plot(x1, y1, startX, startY, px1, py1);
     
      Vector<Point2I> oldpath = path;
      path=new Vector<Point2I>(len);
      for(int i=len-1; i>-1; i--) {
        if(calculateProject){
          path.add(new Point2I(px1[i], py1[i]));
        }
        if(px1[i]==x1 && py1[i]==y1) {
          los=true;
          break;
        }
View Full Code Here

    boolean alternatePath=false;
    for(int i=0; i<len; i++) {
      // Have we reached the end ? In that case quit
      if(px[i]==x1 && py[i]==y1) {
        if(calculateProject){
          path.add(new Point2I(px[i], py[i]));
        }
        los=true;
        break;
      }
      // if we are on alternate path, is the path clear ?
      if(alternatePath && !b.isObstacle(px1[len-i-1], py1[len-i-1])) {
        if(calculateProject)
          path.add(new Point2I(px1[len-i-1], py1[len-i-1]));
        continue;
      } else
        alternatePath=false;//come back to ordinary path
     
      //if on ordinary path, or alternate path was not clear
      if(!b.isObstacle(px[i], py[i])) {
        if(calculateProject) {
          path.add(new Point2I(px[i], py[i]));
        }
        continue;
      }
      //if ordinary path wasnt clear
      if(!b.isObstacle(px1[len-i-1], py1[len-i-1])) {
        if(calculateProject)
          path.add(new Point2I(px1[len-i-1], py1[len-i-1]));
        alternatePath=true;//go on alternate path
        continue;
      }
      if(calculateProject)
        path.add(new Point2I(px1[len-i-1], py1[len-i-1]));
      break;
    }
   
    return los;
  }
View Full Code Here

    activeFields.addLast(new fieldT());
   
    // We decide the farthest cells that can be seen by the cone ( using
    // trigonometry.), then we set the active field to be in between them.
    if(startAngle==0) {
      activeFields.getLast().shallow.near = new Point2I(0, 1);
      activeFields.getLast().shallow.far = new Point2I(state.extent.x, 0);
    } else {
      activeFields.getLast().shallow.near = new Point2I(0, 1);
      activeFields.getLast().shallow.far = new Point2I(
          (int) Math.ceil(Math.cos(Math.toRadians(startAngle))
              * state.extent.x),
          (int) Math.floor(Math.sin(Math.toRadians(startAngle))
          * state.extent.y));
//      System.out.println(activeFields.getLast().shallow.isAboveOrContains(new offsetT(0, 10)));
    }
    if(finishAngle==90) {
      activeFields.getLast().steep.near = new Point2I(1, 0);
      activeFields.getLast().steep.far = new Point2I(0, state.extent.y);
    } else {
      activeFields.getLast().steep.near = new Point2I(1, 0);
      activeFields.getLast().steep.far = new Point2I(
          (int) Math.floor(Math.cos(Math.toRadians(finishAngle))
              * state.extent.x),
          (int) Math.ceil(Math.sin(Math.toRadians(finishAngle))
          * state.extent.y));
    }
    Point2I dest = new Point2I(0, 0);

//    // Visit the source square exactly once (in quadrant 1).
//    if (state.quadrant.x == 1 && state.quadrant.y == 1)
//    {
//      actIsBlockedCone(state, dest);
View Full Code Here

  }
  void permissiveConeFov(int sourceX, int sourceY, permissiveMaskT mask,
      int startAngle, int finishAngle)
  {
    coneFovState state = new coneFovState();
    state.source = new Point2I(sourceX, sourceY);
    state.mask = mask;
    state.board = mask.board;
    // state.isBlocked = isBlocked;
    // state.visit = visit;
    // state.context = context;

    //visit origin once
    state.board.visit(sourceX, sourceY);
   
    final int quadrantCount = 4;
    final Point2I quadrants[] = { new Point2I(1, 1), new Point2I(-1, 1),
        new Point2I(-1, -1), new Point2I(1, -1) };

    Point2I extents[] = { new Point2I(mask.east, mask.north),
        new Point2I(mask.west, mask.north),
        new Point2I(mask.west, mask.south),
        new Point2I(mask.east, mask.south) };
   
    int[] angles=new int[12];
    angles[0]=0; angles[1]=90; angles[2]=180; angles[3]=270;
    for(int i=4; i<12; i++) angles[i]=720;//to keep them at the end
    int i=0;
View Full Code Here

TOP

Related Classes of transientlibs.rlforj.math.Point2I

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.