# Character Platformer CharacterBody2D with gravity, jump, and platforms. ```{raw} html ▶ Run in browser ``` **Tags:** `physics` `2d` `character-body` `gravity` `input-actions` A blue block runs and jumps across seven floating ledges above a full-width ground; fall off the bottom of the screen and it respawns near the top. Every piece of it is engine API, with no game framework in between: * ``CharacterBody2D`` + ``move_and_slide`` drive the runner. A character is KINEMATIC: it is never pushed by the simulation, so the demo owns its ``velocity`` outright and ``move_and_slide`` sweeps it, resolves the hits and deflects what is left along the surfaces it touched. * ``is_on_floor`` (classified against the character's ``up_direction``) gates the jump, so it only fires with ground underfoot. * Ledges are ``PhysicsBody2D`` in ``BodyMode.STATIC`` with a ``RectangleShape2D`` collider that is rebuilt whenever their size changes, so what is drawn is exactly what is collided with. * Named input actions bound on the root, so keyboard and pointer feed the same movement code. This is a screen-space (Y-down) world: gravity points at +Y and the character's ``up_direction`` is flipped to -Y so "up" on screen is up for the floor classifier. World gravity only accelerates DYNAMIC bodies, so the character integrates it itself, reading it off the world to keep one source of truth. Controls: A/D or Left/Right = move, Space = jump. Mouse/touch: hold the left or right half of the screen to move, press the top half to jump. Run: uv run python examples/features/physics/character_platformer.py Headless self-check: uv run python examples/features/physics/character_platformer.py --test ## Source ```{literalinclude} ../../examples/features/physics/character_platformer.py :language: python :linenos: ```