Class HexGrid
java.lang.Object
HexGrid
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
void
fillOneHex
(HexTile hTile) int
getFillColor
(HexLocation loc) getHexTile
(HexLocation loc) HexTile[][]
getMap()
int
int
int
getTileColor
(HexLocation loc) int
void
highlightTile
(HexLocation loc) boolean
isValid
(HexLocation loc) boolean
isValidLocation
(HexLocation testLoc) boolean
isWithinOne
(HexLocation loc1, HexLocation loc2) boolean
isWithinTwo
(HexLocation loc1, HexLocation loc2) void
outlineOneHex
(HexTile hTile) void
Removes a regular background or moveable background, allowing setColor to work again.void
void
setAllOutlinesColor
(int outlineColor) void
setAllTileColors
(int tileColor) void
setAllTileOutlines
(int outlineColor) void
setBackground
(processing.core.PImage bgImage) sets the background to imgName.void
setFillColor
(HexLocation loc, int color) int
setTileColor
(HexLocation loc, int tileColor) void
setTileOutlineColor
(HexLocation loc, int color)
-
Constructor Details
-
HexGrid
public HexGrid(processing.core.PApplet p, int hexGen) -
HexGrid
public HexGrid(processing.core.PApplet p)
-
-
Method Details
-
isValidLocation
-
isWithinOne
-
isWithinTwo
-
claimHexLocation
-
removeHexLocation
-
displayHexGrid
public void displayHexGrid() -
fillOneHex
-
outlineOneHex
-
setAllTileColors
public void setAllTileColors(int tileColor) -
setAllTileOutlines
public void setAllTileOutlines(int outlineColor) -
getHexTile
-
getTileColor
-
setTileColor
-
highlightTile
-
getMap
-
getNumRows
public int getNumRows() -
getNumCols
public int getNumCols() -
isValid
-
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
-
getFillColor
-
setTileOutlineColor
-
getTileOutlineColor
-
setAllOutlinesColor
public void setAllOutlinesColor(int outlineColor)
-