Created
April 24, 2014 11:29
-
-
Save PhilipWitte/11251113 to your computer and use it in GitHub Desktop.
Game Engine Update
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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