Class HexGrid


public class HexGrid extends Object
HexGrid Class - useful for tile-based games with more flavor! Inspired from CSRessel's Catan Game & Emmanuel Suriel's Grid class https://github.com/CSRessel/catan/blob/master/src/gui/CatanBoard.java Adapted for Processing
  • Constructor Details

    • HexGrid

      public HexGrid(processing.core.PApplet p, int hexGen)
    • HexGrid

      public HexGrid(processing.core.PApplet p)
  • Method Details

    • isValidLocation

      public boolean isValidLocation(HexLocation testLoc)
    • isWithinOne

      public boolean isWithinOne(HexLocation loc1, HexLocation loc2)
    • isWithinTwo

      public boolean isWithinTwo(HexLocation loc1, HexLocation loc2)
    • claimHexLocation

      public void claimHexLocation(HexLocation loc)
    • removeHexLocation

      public void removeHexLocation(HexLocation loc)
    • displayHexGrid

      public void displayHexGrid()
    • fillOneHex

      public void fillOneHex(HexTile hTile)
    • outlineOneHex

      public void outlineOneHex(HexTile hTile)
    • setAllTileColors

      public void setAllTileColors(int tileColor)
    • setAllTileOutlines

      public void setAllTileOutlines(int outlineColor)
    • getHexTile

      public HexTile getHexTile(HexLocation loc)
    • getTileColor

      public int getTileColor(HexLocation loc)
    • setTileColor

      public int setTileColor(HexLocation loc, int tileColor)
    • highlightTile

      public void highlightTile(HexLocation loc)
    • getMap

      public HexTile[][] getMap()
    • getNumRows

      public int getNumRows()
    • getNumCols

      public int getNumCols()
    • isValid

      public boolean isValid(HexLocation loc)
    • setBackground

      public void setBackground(processing.core.PImage bgImage)
      sets the background to imgName. The img is resized to fit in the grids dimensions. setColor() is disabled
      Parameters:
      imgName -
    • removeBackground

      public void removeBackground()
      Removes a regular background or moveable background, allowing setColor to work again.
    • setFillColor

      public void setFillColor(HexLocation loc, int color)
    • getFillColor

      public int getFillColor(HexLocation loc)
    • setTileOutlineColor

      public void setTileOutlineColor(HexLocation loc, int color)
    • getTileOutlineColor

      public int getTileOutlineColor(HexLocation loc)
    • setAllOutlinesColor

      public void setAllOutlinesColor(int outlineColor)