Package com.codename1.gaming.platformer
A deterministic 2D platformer engine: the character controller, abilities and level model behind the Ledge template, in the spirit of Unity's Corgi Engine.
The simulation is integer only (Fx fixed point, 60 ticks a second) and shared
with the backend, so a run recorded as an InputLog replays identically on the
server (Replay) -- leaderboards, ghosts and speedruns can be verified rather
than trusted.
TileGridandTile: the collision map, written as rows of characters.Body: a kinematic box with slopes, one-way platforms, steps and riding.MovingPlatform: waypoint platforms that carry riders.ActorandAbility: a body driven by an ordered list of abilities --MoveAbility,JumpAbility(coyote time, buffering, variable height, multi-jump, drop-through),CrouchAbility,LadderAbility,WallJumpAbilityandDashAbility.PlatformWorld: steps everything one tick fromInputbits.LevelDataandLevelJson: the JSON level format.
LevelData is not a com.codename1.gaming.level.GameLevel, and
PlatformWorld is not a com.codename1.gaming.level.GameWorld. Those
are authoring data for any game -- layers, elements placed in doubles,
regions streamed in and out -- turned into sprites and models. This package
is a deterministic simulation the server replays, so it holds only whole
tiles and 16.16 fixed point and touches no image. A GameLevel drawn in the
game builder becomes a LevelData through
com.codename1.gaming.platformer.view.GameLevelImport.
InputLogandReplay: recording and verifying runs.
-
ClassDescriptionCreates the stock abilities by name, as level files, power-ups and the editor refer to them.One thing a
Actorcan do -- walk, jump, dash, climb -- as a small, separately tunable unit, in the manner of Corgi Engine's character abilities.A player or an enemy: aBodydriven by an ordered list ofAbilitys.Enemy behaviour as a small state machine of actions and decisions, after Corgi Engine's AI Brain.Produces input for one tick.Holds after a number of ticks in the current state.Runs two actions and combines their buttons, such as a patrol that shoots.Holds with a chance per tick, drawn from the world's deterministicRng.Moves toward the player, jumping at walls ifjumps.A condition that switches state.Holds while the actor's health is at or below a value.Patrols and hops everyintervalticks.Does nothing.Inverts a decision.Walks back and forth, turning at walls and, ifturnAtLedges, at drops.Stands still, facing the player, and fires everyintervalticks.A named state: an action and its outgoing transitions.Holds when the player is within a distance, and optionally in front.Base for entities that are made of solid tiles which come and go: doors, gates and crumbling blocks.A kinematic box that moves through aTileGrid: the platformer's collision controller.A checkpoint: touching it moves the player's respawn point here.Crouching and crawling: holding down on the ground shrinks the body tocrouchHeight, keeping its feet in place.A floor that gives way:delayTicksafter the player first stands on it, its cells vanish, and they come backrespawnTickslater (never, if 0).A horizontal dash onInput#DASH:dashTicksatdashSpeedin the facing direction with gravity off, then acooldownTickswait.A locked door: solid until the player touches it holding the key it names, which is used up.Creates a game's own entity types from level JSON, for typesLevelDatadoes not know.Free flight with no gravity, steered on both axes, for bats, ghosts and drones (and a debug camera hero).16.16 fixed-point arithmetic for the platformer simulation.A game's own rules over aPlatformWorld: when it is won, when it is lost, what happens when an actor dies and what is checked every tick.A gate wired to a channel: open while the channel is on (or off, wheninverted).Gliding: holdingInput#ALT(or jump, whenholdJump) while falling caps the fall atglideFall.Ledge grab: falling past the top corner of a solid tile while holding toward it, the actor catches the edge and hangs (MovementState.GRIPPING).Hit points, invulnerability frames and knock-back for aActor.The buttons an actor reads, as bits of oneintper tick.A recorded run: oneInputvalue per tick, run-length encoded.A jetpack: holdingInput#ALTin the air thrusts upward while fuel lasts; fuel refills on the ground.Jumping, with the forgiveness that makes a platformer feel right:ClimbingTile#LADDERcells.A platformer level as data, read from JSON and turned into aPlatformWorld.Something in a level that is not an actor: a coin, a spring, a door, a projectile, a crumbling block.A small JSON reader and writer for level files, shared by the app and the server.Looking up and down: holding up, or down, while standing still fordelayTickssets a look direction that a camera pans by (seegetLook()).Horizontal movement: walking, running whileInput#RUNis held, crawling while crouched, with separate acceleration on the ground and in the air.What aActoris doing this tick, which a renderer maps to an animation clip (seeActorAnimator) and abilities read to stay out of each other's way.A platform that travels back and forth along a path of waypoints and carries whatever stands on it.A collectible: a coin or gem that scores, a heart that heals, a key, an extra life, or a power-up that switches an ability on.The whole platformer simulation: aTileGrid, itsMovingPlatforms, theActors andLevelEntitys in it, advanced one fixed tick (1/60 s) at a time.A bullet, arrow or fireball: flies at a fixed velocity, optionally falls, and damages the first actor of another team it touches.A crate a player pushes one tile at a time by walking into it, the piece puzzle platformers are built from.Plays a recorded run against a level and reports what happened, which is how a server verifies a score instead of trusting it.The outcome of a replay.SplitMix64, the simulation's only source of randomness.Proves a level can be finished by finding a run that finishes it.What a game counts as progress besides where the hero stands.Makes the world each run starts from, for a game whose levels need more thanLevelData#createWorld(long): anEntityFactory,GameRules.A spring pad that launches whoever lands on it upward atpower, restoring their air jumps.Swimming inTile#WATER: weak gravity, a slow sink, and a stroke upward on each jump press.A lever or a pressure plate on a channel.The collision kinds aTileGridcell can hold, and the actors a level file writes them with.The collision map of a level: a grid ofTilekinds.Wall clinging and wall jumping.Firing onInput#FIRE: projectiles (a blaster, a bow) or a melee swing, with a cooldown, optional ammunition and eight-way aiming from the held directions.Something that happened in a tick that a view should show or play: a jump, a coin, a hit.