Appearance
Lesson 03 — Turn input into movement
Where this lesson fits: the arena has data but the player does not move. This lesson separates device polling from movement rules and makes movement depend on elapsed time.
Time: 2–3 hours
Prerequisites and outcomes
Complete lessons 01–02. By the end, you can distinguish held input from a one-frame press and calculate a frame-rate-independent candidate position.
Prepare and run
- From your learner project's solution folder, follow tutorial chapter 03 steps 1–4.
- Open
Source\Input\InputManager.cs,InputState.cs, andSource\Systems\MovementSystem.cs. Run the app and follow the tutorial's checkpoint. - Stage note: the staged movement tests arrive in tutorial chapter 04, not chapter 03. Run
dotnet testnow for existing tests; run the focused movement test after lesson 04.
Code anchors
last-perimeter/Source/Input/InputManager.cslast-perimeter/Source/Input/InputState.cslast-perimeter/Source/Systems/MovementSystem.cslast-perimeter/Source/Entities/Player.cslast-perimeter/Tests/Systems/MovementSystemTests.cs
Guided operations
- Inspect
InputManager.GetCurrentInput. Identify keyboard, gamepad, deadzone, held movement, and edge-triggered actions. - Trace how the immutable
InputStatereachesDetermineDirection. - Calculate a candidate with
position + direction * speed * deltaTime. Compare two frame durations that add up to the same elapsed time. - Observe direction priority when more than one direction is held; do not silently replace the established rule.
- Run the existing tests and move in the game with a keyboard and controller if available:
powershell
dotnet test
dotnet run --project Platforms\DesktopVKCheckpoint
Equivalent elapsed time gives approximately equivalent movement. A held key continues movement, while confirm/cancel/pause are acted on once per press.
Common mistakes
- Applying movement once on key-down instead of every update while held.
- Multiplying speed by frames rather than elapsed seconds.
- Treating a menu press like a held movement direction.
Questions and extension
How should a stick deadzone affect diagonal or noisy input? Use the existing input state as the contract and add a focused test if the behavior changes.

