Optimized tile drawing algorithm