Game loop delegate
Game loops

Next:<game-loop> ( tick-interval-nanos delegate -- loop )


A game-loop object requires a tick-delegate and draw-delegate that together implement the logic that controls the game. Both delegates can also be the same object. A game loop delegate can be any object that provides two methods for the following generic words:
tick* ( delegate -- )

draw* ( tick-slice delegate -- )


tick* will be called at a regular interval determined by the game loop's tick-interval-nanos attribute on the tick delegate. draw* will be invoked on the draw delegate in a tight loop, updating as frequently as possible.

It is possible to change the tick-delegate and draw-delegate slots of a game loop while it is running, for example, to use different delegates to control a game while it's in the menu, paused, or running the main game.