JavaScript Game Loop for Canvas Animations