A quick test made in an attempt to solve the problem of laggy collision. How to play: Use the arrow keys to run around as the red dot. That's it. How it works: The ball needs to check if it is touching the purple lines to know if it collided with them or not. But there are 300 purple lines, and checking all of them in a single frame would take a very long time. So when you start the project, it generates a grid of tiles, each one recording which of the purple lines would be worth the red dot's time if it was in that tile. If that explanation didn't make any sense, hopefully the visualization helps. The tile that the player is closest to should light up, activated any walls that are included in that tile.
Update: June 9 Updated the code to make it a bit neater and faster. June 10: Optimized rendering, added even more walls I came up this grid-hybrid method for a couple of projects that I'm working on. I don't know if this method has been invented already, but usually when I try to invent something new, I find out later that it already exists, has a sixteen-syllable name, and gets taught to first-graders at almost every school on the planet. That said, enjoy.