new Region(topX, topY, botX, botY)
a class representing a region of space on the map.
Parameters:
Name | Type | Description |
---|---|---|
topX |
number | x cord for top left corner |
topY |
number | y cord for top left corner |
botX |
number | x cord for top right corner |
botY |
number | y cord for top right corner |
Members
-
bottomRightCorner :RougeLikePoint
-
the bottom left corner of the region
-
children :Array.<Region>
-
any child regions that exist within this region
-
connectsTo :Object
-
an dict of left,right,up and down arrays of all regions this region directly connects to
-
doors :Array.<RougeLikePoint>
-
an array of cords that doors are at
-
isLeaf
-
a variable that marks if this is the lowest layer of the region IE: a region with no children
-
isRoot
-
a variable that marks if this is the highest layer of the region IE: a region with no parent
-
otherPoints :Array.<RougeLikePoint>
-
an array containing all other points that are not in the main rectangle
-
parent :Region
-
the parent region to this region
-
upperLeftCorner :RougeLikePoint
-
the upper left corner of the region
Methods
-
checkLeaf()
-
check if this is a leaf and update accordingly
-
checkRoot()
-
check if this is a root and update accordingly
-
drawAllChildrenOnCanvas()
-
draw all children onto the canvas
-
getAllLeafs() → {Array.<Region>}
-
return an array of all leafs in this region's children
Returns:
Array.<Region> -
getHeight()
-
returns the height of this region
-
getWidth()
-
returns the width of this region
-
isWithinBounds(x, y)
-
check if a point is within the bounds of the region
Parameters:
Name Type Description x
* y
* -
split(numberOfSplits, minPercentageLeft, forceHorizontal)
-
split this region into two subregions. This makes this no longer a root and adds 2 regions to its children.
Parameters:
Name Type Description numberOfSplits
number how many sub regions should be created
minPercentageLeft
number [PERCENTAGE OUT OF 100] the minimum percentage of area that the smaller sub region needs to have.
forceHorizontal
number above .5 to force a horizontal split, below to force a vertical
-
splitTillWidth(width, height)
-
split this region into subregions, then split those into subregions and so on till regions are all within desired width and height
Parameters:
Name Type Description width
* the target width
height
* the target height
Returns:
-null
-
splitXDeep()
-
split this region into subregions, then split those into subregions and so on for x depth
-
static DrawArrayOntoCanvas(arr, canvasId)
-
Parameters:
Name Type Description arr
Array.<Region> canvasId
*