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 class SwimAbility

  1. Object
  2. Ability
  3. SwimAbility
Swimming in Tile#WATER: weak gravity, a slow sink, and a stroke upward on each jump press. Leaving the water at the surface with a stroke gives a small hop out.

Fields

public int waterGravityGravity in water, fixed point per tick squared.
public int maxSinkFastest sink.
public int strokeUpward speed of a stroke.
public int maxSwimSpeedHorizontal speed limit in water.

Constructors

public SwimAbility()

Methods

public void process(Actor c, PlatformWorld world)Sets velocity and claims a MovementState.
public boolean isInWater()Whether the actor is in water.
public long hashState(long h)Mixes the ability’s own state into a hash, so two runs that diverge inside an ability are caught.
public void reset()Forgets what the ability was in the middle of, when its actor respawns: a dash, a buffered jump or a grip does not outlive a death.

Inherited methods

Field details

waterGravity

public int waterGravity
Gravity in water, fixed point per tick squared.

maxSink

public int maxSink
Fastest sink.

stroke

public int stroke
Upward speed of a stroke.

maxSwimSpeed

public int maxSwimSpeed
Horizontal speed limit in water.

Constructor details

SwimAbility

public SwimAbility()

Method details

process

public void process(Actor c, PlatformWorld world)
Sets velocity and claims a MovementState.

Parameters

c Actor
the actor
world PlatformWorld
the world

isInWater

public boolean isInWater()
Whether the actor is in water.

Returns

true while swimming

hashState

public long hashState(long h)
Mixes the ability’s own state into a hash, so two runs that diverge inside an ability are caught. The default mixes nothing.

Parameters

h long
the running hash

Returns

the updated hash

reset

public void reset()
Forgets what the ability was in the middle of, when its actor respawns: a dash, a buffered jump or a grip does not outlive a death. The default does nothing; an ability with per-run state overrides it.