Trying to make a canvas game engine