How long is a game tick?

From OHRRPGCE-Wiki
Jump to navigation Jump to search

A game tick is one update of the user inputs and game state (including scripts) and a redraw of the screen. Therefore the tick rate is the same as the framerate (unless running at more than 60fps, in which case some frames are skipped).

Every tick, non-stationary heroes and npcs move a number of pixels equal to their speed. An npc moving at speed 5 will move 5 pixels, and therefore take 4 ticks to move one 20x20 tile.

The tick rate/framerate is adjustable in Edit General Game Settings -> Graphics -> Framerate. The default is currently 18.2 ticks per second (inherited from the default rate of the DOS timer).

When you use the plotscripting command wait(n), your script stops running until n ticks have passed.

Note that the contents of the key buffer available to plotscripts are only refreshed once a tick. A while loop which contains no wait commands and wants the user to press a key will loop forever, never detecting any keypresses. Such a loop needs a wait command.