from https://github.com/CoderDojo/htmlgamedev