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
- Object
- 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:
| Char | Kind | Collision |
|---|---|---|
. or space | EMPTY | none |
# | SOLID | blocks from every side |
= | ONE_WAY | stands on its top, passes from below and the sides; drop through with down + jump |
/ | SLOPE_UP | 45 degree floor rising to the right |
\ | SLOPE_DOWN | 45 degree floor falling to the right |
a b | SLOPE_UP_LOW, SLOPE_UP_HIGH | a 22.5 degree rise, two tiles wide |
c d | SLOPE_DOWN_HIGH, SLOPE_DOWN_LOW | a 22.5 degree fall, two tiles wide |
H | LADDER | climbable; the top rung of a ladder can be stood on |
^ | HAZARD | hurts on touch, no collision |
~ | WATER | a swim volume, no collision |
r f | aliases for / and \ | for writers that escape backslashes badly |
Fields
public static final byte EMPTY = 0 | Nothing. |
public static final byte SOLID = 1 | A full block. |
public static final byte ONE_WAY = 2 | A platform that is solid from above only. |
public static final byte SLOPE_UP = 3 | A 45 degree slope rising left to right. |
public static final byte SLOPE_DOWN = 4 | A 45 degree slope falling left to right. |
public static final byte SLOPE_UP_LOW = 5 | The low half of a 22.5 degree rise. |
public static final byte SLOPE_UP_HIGH = 6 | The high half of a 22.5 degree rise. |
public static final byte SLOPE_DOWN_HIGH = 7 | The high half of a 22.5 degree fall. |
public static final byte SLOPE_DOWN_LOW = 8 | The low half of a 22.5 degree fall. |
public static final byte LADDER = 9 | A climbable ladder. |
public static final byte HAZARD = 10 | A damaging cell such as spikes. |
public static final byte WATER = 11 | Water 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 = 0Nothing.
SOLID
public static final byte SOLID = 1A full block.
ONE_WAY
public static final byte ONE_WAY = 2A platform that is solid from above only.
SLOPE_UP
public static final byte SLOPE_UP = 3A 45 degree slope rising left to right.
SLOPE_DOWN
public static final byte SLOPE_DOWN = 4A 45 degree slope falling left to right.
SLOPE_UP_LOW
public static final byte SLOPE_UP_LOW = 5The low half of a 22.5 degree rise.
SLOPE_UP_HIGH
public static final byte SLOPE_UP_HIGH = 6The high half of a 22.5 degree rise.
SLOPE_DOWN_HIGH
public static final byte SLOPE_DOWN_HIGH = 7The high half of a 22.5 degree fall.
SLOPE_DOWN_LOW
public static final byte SLOPE_DOWN_LOW = 8The low half of a 22.5 degree fall.
LADDER
public static final byte LADDER = 9A climbable ladder.
HAZARD
public static final byte HAZARD = 10A damaging cell such as spikes.
WATER
public static final byte WATER = 11Water an actor swims in.
Method details
fromChar
public static int fromChar(char c)Maps a level-file character to its kind.
Parameters
cchar- the character
Returns
the kind, or
-1 for an actor that is not a tiletoChar
public static char toChar(int kind)The canonical level-file character for a kind.
Parameters
kindint- a tile kind
Returns
its character
isSlope
public static boolean isSlope(int kind)Whether a kind is one of the slopes.
Parameters
kindint- 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
kindint- a slope kind
lxint- the distance from the tile’s left edge, fixed point, in
[0, ts] tsint- the tile size, fixed point
Returns
the distance from the tile’s top down to the floor, fixed point