Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.

public final class Tile

  1. Object
  2. Tile

The collision kinds a TileGrid cell can hold, and the actors a level file writes them with.

A level’s tiles are rows of text, one character per cell, which a person or a language model can read and write directly:

CharKindCollision
. or spaceEMPTYnone
#SOLIDblocks from every side
=ONE_WAYstands on its top, passes from below and the sides; drop through with down + jump
/SLOPE_UP45 degree floor rising to the right
\SLOPE_DOWN45 degree floor falling to the right
a bSLOPE_UP_LOW, SLOPE_UP_HIGHa 22.5 degree rise, two tiles wide
c dSLOPE_DOWN_HIGH, SLOPE_DOWN_LOWa 22.5 degree fall, two tiles wide
HLADDERclimbable; the top rung of a ladder can be stood on
^HAZARDhurts on touch, no collision
~WATERa swim volume, no collision
r faliases for / and \for writers that escape backslashes badly

Fields

public static final byte EMPTY = 0Nothing.
public static final byte SOLID = 1A full block.
public static final byte ONE_WAY = 2A platform that is solid from above only.
public static final byte SLOPE_UP = 3A 45 degree slope rising left to right.
public static final byte SLOPE_DOWN = 4A 45 degree slope falling left to right.
public static final byte SLOPE_UP_LOW = 5The low half of a 22.5 degree rise.
public static final byte SLOPE_UP_HIGH = 6The high half of a 22.5 degree rise.
public static final byte SLOPE_DOWN_HIGH = 7The high half of a 22.5 degree fall.
public static final byte SLOPE_DOWN_LOW = 8The low half of a 22.5 degree fall.
public static final byte LADDER = 9A climbable ladder.
public static final byte HAZARD = 10A damaging cell such as spikes.
public static final byte WATER = 11Water an actor swims in.

Methods

public static int fromChar(char c)Maps a level-file character to its kind.
public static char toChar(int kind)The canonical level-file character for a kind.
public static boolean isSlope(int kind)Whether a kind is one of the slopes.
public static int slopeDepth(int kind, int lx, int ts)The floor height of a slope at a point across the tile, measured down from the tile’s top edge.

Inherited methods

Field details

EMPTY

public static final byte EMPTY = 0
Nothing.

SOLID

public static final byte SOLID = 1
A full block.

ONE_WAY

public static final byte ONE_WAY = 2
A platform that is solid from above only.

SLOPE_UP

public static final byte SLOPE_UP = 3
A 45 degree slope rising left to right.

SLOPE_DOWN

public static final byte SLOPE_DOWN = 4
A 45 degree slope falling left to right.

SLOPE_UP_LOW

public static final byte SLOPE_UP_LOW = 5
The low half of a 22.5 degree rise.

SLOPE_UP_HIGH

public static final byte SLOPE_UP_HIGH = 6
The high half of a 22.5 degree rise.

SLOPE_DOWN_HIGH

public static final byte SLOPE_DOWN_HIGH = 7
The high half of a 22.5 degree fall.

SLOPE_DOWN_LOW

public static final byte SLOPE_DOWN_LOW = 8
The low half of a 22.5 degree fall.

LADDER

public static final byte LADDER = 9
A climbable ladder.

HAZARD

public static final byte HAZARD = 10
A damaging cell such as spikes.

WATER

public static final byte WATER = 11
Water an actor swims in.

Method details

fromChar

public static int fromChar(char c)
Maps a level-file character to its kind.

Parameters

c char
the character

Returns

the kind, or -1 for an actor that is not a tile

toChar

public static char toChar(int kind)
The canonical level-file character for a kind.

Parameters

kind int
a tile kind

Returns

its character

isSlope

public static boolean isSlope(int kind)
Whether a kind is one of the slopes.

Parameters

kind int
a tile kind

Returns

true for the six slope kinds

slopeDepth

public static int slopeDepth(int kind, int lx, int ts)
The floor height of a slope at a point across the tile, measured down from the tile’s top edge.

Parameters

kind int
a slope kind
lx int
the distance from the tile’s left edge, fixed point, in [0, ts]
ts int
the tile size, fixed point

Returns

the distance from the tile’s top down to the floor, fixed point