commands/cheat_sequences¶
Goal¶
Implement a cheat-code manager that detects specific key sequences and triggers game-altering effects.
Why this tutorial exists¶
Classic games often have hidden key sequences (Konami code, etc.) that
unlock special modes. This tutorial shows how to build a CheatManager
that:
buffers recent key presses
matches them against registered cheat patterns
fires callbacks when a sequence completes
displays active cheat status on a panel
Source map¶
Settings profile:
examples/settings/commands/cheat_sequences.ymlExample builder:
examples/catalog/commands/cheat_sequences/main.pyScene:
examples/catalog/commands/cheat_sequences/scenes/scene.pyShared runner:
examples/_shared/runner.py
What to verify¶
You should see:
a status panel showing registered cheat codes and their activation state
typing the correct key sequence (shown on screen) activates the cheat
an activation flash confirms the match
active cheats display as “ON” in the panel
Example sequences (from the demo):
G O D— toggles god modeUp Up— toggles double jumpF A S T— toggles speed boost
Behavior checks:
partial sequences don’t trigger (typing
G OthenXresets the buffer)activating the same cheat again toggles it off
the key buffer has a maximum length and drops old keys
Controls¶
Keys |
Cheat |
|---|---|
|
God mode |
|
Double jump |
|
Speed boost |
|
Quit |
Run¶
mini-arcade run --example commands/cheat_sequences
mini-arcade run --example commands/cheat_sequences --pass-through --backend pygame
mini-arcade run --example commands/cheat_sequences --pass-through --backend native
Common mistakes¶
Not clearing the key buffer between scenes — old keys leak into new sequences.
Using
keys_heldinstead ofkeys_pressed— held keys repeat every frame.Making sequences too long — players won’t remember them.