gameloop

Functions

gameloop

(callback: () ⇨ void) ⇨ void

Creates the game loop. The method use the window.requestAnimationFrame function inside


Example:

gameloop(() => {
  
  // a some code here
  
  console.log(Time.fps)
})

killgameloop

() ⇨ void

Removes the game loop. The method use the window.cancelAnimationFrame function inside


Example:

gameloop(() => {
  for (const ev of game.events.get()) {
    if (ev.type === "KEYDOWN" && ev.key === Key.ESCAPE) {
      killgameloop()
      return
    }
  }

  // a some code here
})