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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • generateInto

      public 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. 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 possible
      xPos - the minimum x to modify; the maximum will be xPos + 12, exclusive
      yPos - the minimum y to modify; the maximum will be yPos + 12, exclusive
      Returns:
      changing, after modifications
    • generate

      public 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. The technique used here is derived from https://github.com/zfedoran/pixel-sprite-generator .
      Returns:
      an int array with the randomly generated shape.
    • generate

      public 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. 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

      public 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. 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 possible
      xPos - the minimum x to modify; the maximum will be xPos + 12, exclusive
      yPos - the minimum y to modify; the maximum will be yPos + 12, exclusive
      Returns:
      changing, after modifications
    • generateIntoShaded8way

      public 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. 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 possible
      xPos - the minimum x to modify; the maximum will be xPos + 12, exclusive
      yPos - the minimum y to modify; the maximum will be yPos + 12, exclusive
      Returns:
      changing, after modifications