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
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 waterGravity | Gravity in water, fixed point per tick squared. |
public int maxSink | Fastest sink. |
public int stroke | Upward speed of a stroke. |
public int maxSwimSpeed | Horizontal 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
From Ability
Field details
waterGravity
public int waterGravityGravity in water, fixed point per tick squared.
maxSink
public int maxSinkFastest sink.
stroke
public int strokeUpward speed of a stroke.
maxSwimSpeed
public int maxSwimSpeedHorizontal 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
cActor- the actor
worldPlatformWorld- 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
hlong- 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.