Make attacks take the same time on slow and fast computers
On a fast screen your sword swings quicker and on a slow one the enemy gets extra hits. This entry shows how to count game time in even steps so a swing lasts the same everywhere, and what to do when a computer stalls for a moment.
Why this works
Fairness in a fight depends on every swing lasting the same real time for everyone. Drawing speed differs from machine to machine, but game rules can run on their own steady beat, so the screen shows the result at whatever pace it manages.
When not to use it
Skip it for a slow turn-based game where nothing depends on how long a swing takes: counting turns is simpler. For very smooth motion of far-away scenery, let the drawing blend between two beats instead.
In the full entry
- What to build, step by step
- Starting values and the reason for each
- 3 common mistakes and the fix
- 30 lines of example code with 4 checks that pass
- How your AI shows you that it works
Say this to your AI
Use the Spielerando entry "Make attacks take the same time on slow and fast computers" (read_entry fixed-step-attack-timing) in my game. Build it step by step, and show me how you checked that it works.Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP