Move tile direction helpers into tiles.js, remove direction4 -> direction16 conversion magic numbers