Class PushBlock
A crate a player pushes one tile at a time by walking into it, the piece
puzzle platformers are built from. It is solid while it rests, so it can be
stood on and climbed; it falls when nothing holds it up, and it holds down
a pressure plate (Switch) as a player standing on it would.
A push takes pushTicks of walking against it, so brushing past never
moves it, and a crate only moves into empty cells. Movement is in whole
tiles, which keeps a puzzle exactly solvable and a replay exact.
-
Field Summary
FieldsModifier and TypeFieldDescriptionintTicks one tile of movement takes.intTicks of pushing before the crate moves.Fields inherited from class LevelEntity
h, w, x, y -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintgetPhase()A small number the view reads to pick a frame: open or closed, lit or not, how cracked.longhashState(long h) Mixes the entity's play-relevant state into a hash.booleanisMoving()Whether the crate is sliding or falling.voidonAdded(PlatformWorld world) Called once when the entity is added to a world, before the first step: the place to write solid cells.voidonTouch(PlatformWorld world, Actor c) Called each tick a living actor overlaps the entity.voidstep(PlatformWorld world) Advances one tick.Methods inherited from class BlockEntity
getTouchMargin, isSolid, setSolidMethods inherited from class LevelEntity
deactivate, getId, getType, isActive
-
Field Details
-
pushTicks
public int pushTicksTicks of pushing before the crate moves. -
moveTicks
public int moveTicksTicks one tile of movement takes.
-
-
Constructor Details
-
PushBlock
Creates a crate one tile in size.
Parameters
id: the idx: left, fixed point, on a tile edgey: top, fixed point, on a tile edgesize: the tile size, fixed point
-
-
Method Details
-
onAdded
Description copied from class:LevelEntityCalled once when the entity is added to a world, before the first step: the place to write solid cells. The default does nothing.
Parameters
world: the world
- Overrides:
onAddedin classLevelEntity
-
isMoving
public boolean isMoving()Whether the crate is sliding or falling.
Returns
true mid-move
-
getPhase
public int getPhase()Description copied from class:LevelEntityA small number the view reads to pick a frame: open or closed, lit or not, how cracked. The default is 0.
Returns
the visual phase
- Overrides:
getPhasein classLevelEntity
-
step
Description copied from class:LevelEntityAdvances one tick. The default does nothing.
Parameters
world: the world
- Overrides:
stepin classLevelEntity
-
onTouch
Description copied from class:LevelEntityCalled each tick a living actor overlaps the entity.
Parameters
world: the worldc: the actor
- Overrides:
onTouchin classLevelEntity
-
hashState
public long hashState(long h) Description copied from class:LevelEntityMixes the entity's play-relevant state into a hash. The default mixes the position and whether it is active.
Parameters
h: the running hash
Returns
the updated hash
- Overrides:
hashStatein classBlockEntity
-