Ticks
An Easel game runs at 60 ticks per second. That means it performs all game logic and rendering 60 times per second.
Awaiting the next tick
The function await Tick(interval?) can be used to wait for a specific number of ticks.
If no interval is provided, it will wait for the next tick.
await Tick // await until the next tick
await Tick(10) // wait for 10 ticks
await Tick(5s) // wait for 5 seconds (300 ticks)
It is possible to wait for a different phase of a tick using the appropriate function.
await BeforePhysics // wait until just before the Physics phase
await Paint // wait for the Paint phase
Anatomy of a tick
Each tick proceeds as follows:
BeforeTickhooks are triggered.Pointerhooks are triggered with new mouse pointer positions, if any. This is early in the tick so that it can be incorporated in any player movement before the physics engine runs.BeforePhysicshooks are triggered.- Physics calculations are performed.
BeforeCollideandAfterCollidehooks are triggered.AfterPhysicshooks are triggered.Tickhooks are triggered. This hook should be used for most game logic.- All inputs are received and processed.
This includes keyboard events like
ButtonDownandButtonUp, user interface events likePressed, player events likePlayerJoinedorBeforePlayerLeave, and persistence events likeFetchLeaderboard. BeforeReaphooks are triggered.- All entities that have been set to
Expireare despawned, first triggering theirBeforeDespawnhooks. AfterReaphooks are triggered.AfterTickhooks are triggered.Painthooks are triggered. This hook should be used for rendering. It is last so that it can see the final state of the tick and show that to the user.
Sleeping
If there have been no inputs for 1 minute, the game will go to sleep and ticks will not be processed.
When a new input is received, the game will start ticking again.
It may be possible that await Tick hooks for example may run after their designated tick because of this.
This is a feature to save server resources when the game is not being played.
As even moving the mouse counts as input, it is unlikely this would occur within a normal game.