Examples of MazeCell


Examples of maze.model.MazeCell

      {
         //Draw the fog of war.
         if (this.drawFog && !this.robotPathModel.hasCellBeenVisited(cell))
         {
            final Rectangle area = this.getCellArea(cell);
            final MazeCell east = cell.neighbor(Direction.East);
            final MazeCell south = cell.neighbor(Direction.South);
            if (east.isInRange(this.model.getSize()) &&
                this.robotPathModel.hasCellBeenVisited(east))
            {
               area.width -= this.csm.getWallWidth();
            }
            if (south.isInRange(this.model.getSize()) &&
                this.robotPathModel.hasCellBeenVisited(south))
            {
               area.height -= this.csm.getWallHeight();
            }
            this.painter.drawFog(g, area);
View Full Code Here

Examples of maze.model.MazeCell

   private void drawPath(final Graphics2D g, final List<MazeCell> path, final int offset,
         boolean trimTail)
   {
      if (path != null && !path.isEmpty())
      {
         MazeCell here = path.get(0);
         MazeCell there;
         int x, y;
         int width, height;
         for (int i = 1; i < path.size(); i++)
         {
            there = path.get(i);
            // Check for a rare case where a lack of thread safety changes the list while in use.
            if (there == null)
               return;
            final Point center = this.getCellCenterInner(here);
            if (here.getX() < there.getX())
            {
               //here is west of there, going east.
               x = center.x + this.csm.getWallWidthHalf();
               y = center.y - this.csm.getWallHeightHalf();
               width = this.csm.getCellWidth();
               height = this.csm.getWallHeight();
            }
            else if (here.getX() > there.getX())
            {
               //here is east of there, going west.
               x = center.x - this.csm.getWallWidthHalf() - this.csm.getCellWidth();
               y = center.y - this.csm.getWallHeightHalf();
               width = this.csm.getCellWidth();
               height = this.csm.getWallHeight();
            }
            else if (here.getY() > there.getY())
            {
               //here is south of there, going north.
               x = center.x - this.csm.getWallWidthHalf();
               y = center.y - this.csm.getWallHeightHalf() - this.csm.getCellHeight();
               width = this.csm.getWallWidth();
               height = this.csm.getCellHeight();
            }
            else
            {
               //here is north of there, going south.
               x = center.x - this.csm.getWallWidthHalf();
               y = center.y + this.csm.getWallHeightHalf();
               width = this.csm.getWallWidth();
               height = this.csm.getCellHeight();
            }
            // If we are at the last cell and we are trimming the tail up to the robot.
            if (i == path.size() - 1 && trimTail && this.robotLocation != null)
            {
               if (here.getX() < there.getX())
               {
                  //here is west of there, going east.
                  width = Math.abs(x - this.robotLocation.x);
               }
               else if (here.getX() > there.getX())
               {
                  //here is east of there, going west.
                  width -= this.robotLocation.x - x;
                  x = this.robotLocation.x;

               }
               else if (here.getY() > there.getY())
               {
                  //here is south of there, going north.
                  height -= this.robotLocation.y - y;
                  y = this.robotLocation.y;
               }
View Full Code Here

Examples of maze.model.MazeCell

         }
       
         // Use the top left corner of the peg next to the center point.
         final Point pegCorner = new Point(centerPoints[i].x - csm.getWallWidth(),
                                           centerPoints[i].y - csm.getWallHeightHalf());
         final MazeCell hostCell = this.getHostMazeCell(pegCorner);
         if (hostCell != null)
         {
            // The goal here is to check if the peg under the cursor is hovering over a peg on the maze.
            final Rectangle cellAreaInner = super.getCellAreaInner(hostCell);
            // The bottom right peg, take the top left corner, and move one wall height-width to the top-left direction.
            final Point cellLimitPoint = new Point(cellAreaInner.x +
                                                   cellAreaInner.width -
                                                   csm.getWallWidth(), cellAreaInner.y +
                                                                       cellAreaInner.height -
                                                                       csm.getWallHeight());
            // If in range of the peg then apply the template to the maze.
            if (pegCorner.x > cellLimitPoint.x && pegCorner.y > cellLimitPoint.y)
            {
               final TreeSet<TemplatePeg> visited = new TreeSet<TemplatePeg>();
               int[] coords =
               {
                  hostCell.getXZeroBased(), hostCell.getYZeroBased()
               };
               applyPeg(centerPegs[i], visited, walls, coords);
               appliedPegs.addAll(visited);
            }
         }
View Full Code Here

Examples of maze.model.MazeCell

      try
      {
         // If the pointer is on the North or West border wall.
         if (pointerLocation.x < csm.getWallWidth() || pointerLocation.y < csm.getWallHeight())
            return null;
         MazeCell cell = MazeCell.valueOf( ( (pointerLocation.x - csm.getWallWidth()) / csm.getCellWidth()) + 1,
                                          ( (pointerLocation.y - csm.getWallHeight()) / csm.getCellHeight()) + 1);
         if (cell.isInRange(this.model.getSize()))
            return cell;
      }
      catch (IllegalArgumentException e)
      {}
      return null;
View Full Code Here

Examples of maze.model.MazeCell

    * @return The maze wall that can be checked or changed, or null if the
    *         pointer is not over a wall.
    */
   protected MazeWall getWall(Point pointerLocation)
   {
      final MazeCell cell = this.getHostMazeCell(pointerLocation);
      if (cell != null)
      {
         if (super.getWallArea(cell, Direction.East).contains(pointerLocation))
            return super.model.getWall(cell, Direction.East);
         if (super.getWallArea(cell, Direction.South).contains(pointerLocation))
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.