attempted and non-functional port of tile code to javascript