Tick: Difference between revisions

From Wiki of ZZT
Jump to navigation Jump to search
(Created page with "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: <code>Cycle =/= 0</code> and <code>TickCounter % Cycle == StatIndex % Cycle</code>, where: * <code>Cycle</code> refers to the stat's Cycle value, * <code>TickCou...")
 
Line 11: Line 11:
The tick counter is set to a random value between 0 and 99 on start, and is incremented until it reaches the value <code>420</code>, after which it is reset back to <code>1</code>. 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.
The tick counter is set to a random value between 0 and 99 on start, and is incremented until it reaches the value <code>420</code>, after which it is reset back to <code>1</code>. 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.


== Tick rate ==
== 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 [[play|sounds]] is not affected by the game speed.


The tick rate is dependent on the game speed, and is always a number of PIT ticks (approximately 18.2 Hz). Importantly, the speed of [[play|sounds]] is not affected.
{| class="wikitable"
{| class="wikitable"
|+
|+
! Game speed
! Game speed
! Intended tick period
! PIT ticks per game tick
! PIT ticks per game tick
! Effective tick frequency
! Effective tick period
|-
|-
| 0 (F)
| 0 (F)
| 0 ms (Uncapped)
| 0
| 0
| Uncapped
| Uncapped
|-
|-
| 1
| 1
| 20 ms (50 Hz)
| rowspan="2" | 1
| rowspan="2" | 1
| rowspan="2" | 18.2 Hz
| rowspan="2" | 55 ms (18.2 Hz)
|-
|-
| 2
| 2
| 40 ms (25 Hz)
|-
|-
| 3
| 3
| 60 ms (16.67 Hz)
| rowspan="3" | 2
| rowspan="3" | 2
| rowspan="3" | 9.1 Hz
| rowspan="3" | 110 ms (9.1 Hz)
|-
|-
| 4 (default)
| 4 (default)
| 80 ms (12.5 Hz)
|-
|-
| 5
| 5
| 100 ms (10 Hz)
|-
|-
| 6
| 6
| 120 ms (8.33 Hz)
| rowspan="3" | 3
| rowspan="3" | 3
| rowspan="3" | 6.06 Hz
| rowspan="3" | 165 ms (6.06 Hz)
|-
|-
| 7
| 7
| 140 ms (7.14 Hz)
|-
|-
| 8 (S)
| 8 (S)
| 160 ms (6.25 Hz)
|}
|}


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

Revision as of 13:22, 24 December 2025

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.