Tick

From Wiki of ZZT
Revision as of 13:22, 24 December 2025 by Asie (talk | contribs) (→‎Tick rate)
Jump to navigation Jump to search

The fundamental unit of time in a ZZT world is the tick. During a tick, the player input is collected, after which all stats are processed in order based on their cycle.

Cycle handling

Whether a given stat is processed on a given tick is based on the following conditions: Cycle =/= 0 and TickCounter % Cycle == StatIndex % Cycle, where:

  • Cycle refers to the stat's Cycle value,
  • TickCounter refers to the game's tick counter,
  • StatIndex refers to the stat's index.

The tick counter is set to a random value between 0 and 99 on start, and is incremented until it reaches the value 420, after which it is reset back to 1. This has a consequence of only divisors of 420 ticking at a consistent rate throughout gameplay: 1, 2, 3, 4, 5, 6, 7, 10, 12, 14, 15, 20, 21, 28, 30, 35, 42, 60, 70, 84, 105, 140, 210 and 420. Other cycle values, such as 8, 9, 11..., will eventually skip cycles. In addition, as all stats have a lower index than 420 (and all non-player stats have a higher index than 0), stats with a cycle rate higher than 420 will tick as if they had a cycle rate of 420.

Game speed

The rate at which the world ticks is dependent on the game speed.

While ZZT's code intended to support a variety of game speeds, in practice on most machines and all emulators the speed is always a multiple of PIT ticks (approximately 18.2 Hz).

The speed of sounds is not affected by the game speed.

Game speed Intended tick period PIT ticks per game tick Effective tick period
0 (F) 0 ms (Uncapped) 0 Uncapped
1 20 ms (50 Hz) 1 55 ms (18.2 Hz)
2 40 ms (25 Hz)
3 60 ms (16.67 Hz) 2 110 ms (9.1 Hz)
4 (default) 80 ms (12.5 Hz)
5 100 ms (10 Hz)
6 120 ms (8.33 Hz) 3 165 ms (6.06 Hz)
7 140 ms (7.14 Hz)
8 (S) 160 ms (6.25 Hz)

Most ZZT worlds are designed for the default tick speed, which is equal to 4, or approximately 9.1 Hz.