Package squidpony.squidmath
Class MaskedShapeGenerator
java.lang.Object
squidpony.squidmath.MaskedShapeGenerator
public class MaskedShapeGenerator extends Object
Generates procedural shapes based on a mask that determines what values can exist at a location.
Currently, this generates spaceship-like shapes, which look like this.
The technique used here is derived from this repo,
which is an adaptation of
Dave
Bollinger's work.
Created by Tommy Ettinger on 10/12/2017.
-
Field Summary
Fields Modifier and Type Field Description static GreasedRegion
alwaysSolid
static GreasedRegion
potentialBody
static GreasedRegion
potentialSolid
Starfish32RNG
randomness
GreasedRegion
randomRegion
static int[][]
spaceship
-
Constructor Summary
Constructors Constructor Description MaskedShapeGenerator()
-
Method Summary
Modifier and Type Method Description int[][]
generate()
Returns an int array (12x12) where 0 represents empty space, 1 represents border, and 2 represents "body." The seed will change each time this runs, producing different shapes each time.int[][]
generate(long seed)
Returns an int array (12x12) where 0 represents empty space, 1 represents border, and 2 represents "body." Will use the specified seed for this generation.int[][]
generateInto(int[][] changing, int xPos, int yPos)
Returns a modified version of changing where 0 represents empty space, 1 represents border, and 2 represents "body." Only a 12x12 area will be changed by this call, with its minimum x and y determined by xPos and yPos.int[][]
generateIntoShaded(int[][] changing, int xPos, int yPos)
Returns a modified version of changing where 0 represents empty space, 1 represents border, 2 represents shaded "body,", 3 represents normal body, and 4 represents lit body.int[][]
generateIntoShaded8way(int[][] changing, int xPos, int yPos)
Returns a modified version of changing where 0 represents empty space, 1 represents border, 2 represents shaded "body,", 3 represents normal body, and 4 represents lit body.
-
Field Details
-
Constructor Details
-
MaskedShapeGenerator
public MaskedShapeGenerator()
-
-
Method Details
-
generateInto
Returns a modified version of changing where 0 represents empty space, 1 represents border, and 2 represents "body." Only a 12x12 area will be changed by this call, with its minimum x and y determined by xPos and yPos. The seed will change each time this runs, producing different shapes each time. The technique used here is derived from https://github.com/zfedoran/pixel-sprite-generator .- Parameters:
changing
- an int array that will be altered if possiblexPos
- the minimum x to modify; the maximum will be xPos + 12, exclusiveyPos
- the minimum y to modify; the maximum will be yPos + 12, exclusive- Returns:
- changing, after modifications
-
generate
Returns an int array (12x12) where 0 represents empty space, 1 represents border, and 2 represents "body." The seed will change each time this runs, producing different shapes each time. The technique used here is derived from https://github.com/zfedoran/pixel-sprite-generator .- Returns:
- an int array with the randomly generated shape.
-
generate
Returns an int array (12x12) where 0 represents empty space, 1 represents border, and 2 represents "body." Will use the specified seed for this generation. The technique used here is derived from https://github.com/zfedoran/pixel-sprite-generator .- Parameters:
seed
- a long to use as the seed for this random shape.- Returns:
- an int array with the randomly generated shape.
-
generateIntoShaded
Returns a modified version of changing where 0 represents empty space, 1 represents border, 2 represents shaded "body,", 3 represents normal body, and 4 represents lit body. Only a 12x12 area will be changed by this call, with its minimum x and y determined by xPos and yPos. The seed will change each time this runs, producing different shapes each time. The technique used here is derived from https://github.com/zfedoran/pixel-sprite-generator .- Parameters:
changing
- an int array that will be altered if possiblexPos
- the minimum x to modify; the maximum will be xPos + 12, exclusiveyPos
- the minimum y to modify; the maximum will be yPos + 12, exclusive- Returns:
- changing, after modifications
-
generateIntoShaded8way
Returns a modified version of changing where 0 represents empty space, 1 represents border, 2 represents shaded "body,", 3 represents normal body, and 4 represents lit body. Only a 12x12 area will be changed by this call, with its minimum x and y determined by xPos and yPos. Ensures that borders drawn around the shape cover all cells that are 8-way adjacent to any cells in the shape. The seed will change each time this runs, producing different shapes each time. The technique used here is derived from https://github.com/zfedoran/pixel-sprite-generator .- Parameters:
changing
- an int array that will be altered if possiblexPos
- the minimum x to modify; the maximum will be xPos + 12, exclusiveyPos
- the minimum y to modify; the maximum will be yPos + 12, exclusive- Returns:
- changing, after modifications
-