WASD to look around Scroll to zoom in/out
This is my 2nd attempt at making a perfectly efficient tile renderer, this was the first: scratch.mit.edu/projects/1054639906 In my previous attempt I just added optimizations as I went along, without putting enough thought into them, causing it to become a horrible mess, where I could barely tell what half of my code did. This time everything has a purpose. The reason the Render script might still look like a mess is because to achieve maximum performace, we cannot simply render the entire map at once, we have to split it into chunks based on the edges they are touching, so we can individually decide for each chunk if we need to use a larger costume to avoid offscreen fencing (where tiles would get stuck on the edges). The way it works in this project is that it first renders the bottom left corner, then the bottom row, the bottom right corner, the middle, the top left corner, top row, top right corner, left column and finally right column. Also there are plenty of edge cases where we wouldn't want to render an individual chunk, but to optimize it more, the values from previous chunks are reused in future chunks, which also means that if we don't account for it when skipping rendering previous chunks, the tiles in future chunks will be rendered incorrectly. This unavoidably makes it look like a mess, but I still tried to keep it as clean as I could. It's definitelly an improvement from my previous attempt at the very least.