Skip to content

Instantly share code, notes, and snippets.

@PhilipWitte
Created April 24, 2014 11:29
Show Gist options
  • Save PhilipWitte/11251113 to your computer and use it in GitHub Desktop.
Save PhilipWitte/11251113 to your computer and use it in GitHub Desktop.
Game Engine Update
# engine.nim
proc update* =
Time.update()
Input.update() # update input every cycle (raw input)
GameParts.rawUpdate() # respond to input changes (often minimal, if needed at all)
if Time.elapsed >= Time.fixedStep:
Physics.update() # either unique thread, or uses thread pool
if Physics.isDone: # awaits physics
GameParts.fixedUpdate() # sometimes this is also threaded, which complicates things a bit more
Physics.reset()
if Canvas.isReady: # GPU synced
Animation.update() # samples from animations (sometimes threaded, but not sure best practice here)
GameParts.update() # most game-code goes here (ditto)
Canvas.update() # renders screen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment