Skip to content

TilesetFactory

sirrandalot edited this page Mar 16, 2018 · 3 revisions

TilesetFactory contains static methods for creating Tilesets.


Methods:

static Tileset createTileset(int tileWidth, int tileHeight, int numT)

  • Returns a blank Tileset given the tile size and number of tiles.

static Tileset createTileset(int tileWidth, int tileHeight, int numT, int[] vals)

  • Returns a Tileset based on an array of values.

static Tileset createTileset(int tileWidth, int tileHeight, int numT, Tile[] tiles)

  • Returns a Tileset based on an array of tiles.

static Tileset createTileset(TilesetPredef t)

  • Returns a pre-defined Tileset based on a TilesetPredef enum value.

static Tileset getTilesetFromImage(BufferedImage img, int tileWidth, int tileHeight, int numX, int numY, int thresh)

  • Returns a Tileset based on a BufferedImage and given the tile size as well as how many horizontal and vertical columns/rows there are in the image.
  • Currently, the red value of the image pixel is used to determine whether a value is 0 or 1, and thresh is used as the threshold: if red value > thresh, a pixel will be foreground.