Created
March 10, 2013 04:08
-
-
Save molant/5127080 to your computer and use it in GitHub Desktop.
Game Loop example for video editing project
This file contains 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
function tick(){ | |
//we clean if we've changed the size of the quadrant | |
if(needsClean){ | |
cleanCanvas(); | |
} | |
//if we have to change the quadrant's frame because we are the active one (or the opposite) | |
if(newFrame){ | |
drawFrame(); //we draw just the frame in a separate canvas so it doesn't need to be calculated all the time, and it is still faster than copying from an image | |
} | |
//we draw the new frame if we are playing or seeking | |
if(dirty){ | |
draw(); | |
drawFrameInQuadrant(); | |
} | |
requestAnimationFrame(tick); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment