Optimize tile graphics rendering

Replace the simple tilerender function to a tile system that can index
tiles by their position. The game speed is now back to normal.