Class Tile
java.lang.Object
com.codename1.gaming.platformer.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 |
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final byteNothing.static final byteA damaging cell such as spikes.static final byteA climbable ladder.static final byteA platform that is solid from above only.static final byteA 45 degree slope falling left to right.static final byteThe high half of a 22.5 degree fall.static final byteThe low half of a 22.5 degree fall.static final byteA 45 degree slope rising left to right.static final byteThe high half of a 22.5 degree rise.static final byteThe low half of a 22.5 degree rise.static final byteA full block.static final byteWater an actor swims in. -
Method Summary
Modifier and TypeMethodDescriptionstatic intfromChar(char c) Maps a level-file character to its kind.static booleanisSlope(int kind) Whether a kind is one of the slopes.static intslopeDepth(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.static chartoChar(int kind) The canonical level-file character for a kind.
-
Field Details
-
EMPTY
public static final byte EMPTYNothing.- See Also:
-
SOLID
public static final byte SOLIDA full block.- See Also:
-
ONE_WAY
public static final byte ONE_WAYA platform that is solid from above only.- See Also:
-
SLOPE_UP
public static final byte SLOPE_UPA 45 degree slope rising left to right.- See Also:
-
SLOPE_DOWN
public static final byte SLOPE_DOWNA 45 degree slope falling left to right.- See Also:
-
SLOPE_UP_LOW
public static final byte SLOPE_UP_LOWThe low half of a 22.5 degree rise.- See Also:
-
SLOPE_UP_HIGH
public static final byte SLOPE_UP_HIGHThe high half of a 22.5 degree rise.- See Also:
-
SLOPE_DOWN_HIGH
public static final byte SLOPE_DOWN_HIGHThe high half of a 22.5 degree fall.- See Also:
-
SLOPE_DOWN_LOW
public static final byte SLOPE_DOWN_LOWThe low half of a 22.5 degree fall.- See Also:
-
LADDER
public static final byte LADDERA climbable ladder.- See Also:
-
HAZARD
public static final byte HAZARDA damaging cell such as spikes.- See Also:
-
WATER
public static final byte WATERWater an actor swims in.- See Also:
-
-
Method Details
-
fromChar
public static int fromChar(char c) Maps a level-file character to its kind.
Parameters
c: the character
Returns
the kind, or
-1for an actor that is not a tile -
toChar
public static char toChar(int kind) The canonical level-file character for a kind.
Parameters
kind: a tile kind
Returns
its character
-
isSlope
public static boolean isSlope(int kind) Whether a kind is one of the slopes.
Parameters
kind: 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: a slope kindlx: the distance from the tile's left edge, fixed point, in[0, ts]ts: the tile size, fixed point
Returns
the distance from the tile's top down to the floor, fixed point
-