based on the tutorial at https://developer.mozilla.org/en-US/docs/Games/Tutorials/2D_Breakout_game_pure_JavaScript and incorporating http://isaacsukin.com/news/2015/01/detailed-explanation-javascript-game-loops-and-timing#timing-problems implementation of the timing.