This class uses the cellular automata algorithm to generate very sexy caves. (Coded by Eddie Lee, October 16, 2010)
Static methods
staticconvertMatrixToString(Matrix:Array<Array<Int>>):String
Convert a matrix generated via generateCaveMatrix() into data that is usable by FlxTilemap.
Parameters:
Matrix | A matrix of data |
---|
Returns:
A string that is usuable for FlxTilemap.loadMap()
staticgenerateCaveMatrix(Columns:Int, Rows:Int, SmoothingIterations:Int = 6, WallRatio:Float = 0.5):Array<Array<Int>>
Generate the matrix (2-dimensional array of Ints) for a cave.
Parameters:
Columns | Number of columns for the matrix |
---|---|
Rows | Number of rows for the matrix |
SmoothingIterations | How many times do you want to "smooth" the caev - the higher the smoother, but slower |
WallRatio | Chance for a tile to become a wall - the closer the value is to 1.0, the more walls there are |
Returns:
A matrix of a cave!
staticinlinegenerateCaveString(Columns:Int, Rows:Int, SmoothingIterations:Int = 6, WallRatio:Float = 0.5):String
Generates a new cave matrix via generateCaveMatrix() and returns it in a format usable by FlxTilemap.load() via convertMatrixToString().
Parameters:
Columns | Number of columns for the matrix |
---|---|
Rows | Number of rows for the matrix |
SmoothingIterations | How many times do you want to "smooth" the caev - the higher the smoother, but slower |
WallRatio | Chance for a tile to become a wall - the closer the value is to 1.0, the more walls there are |
Returns:
A cave string that is usable by FlxTilemap.loadMap()