r/PirateSoftware • u/dsruptorPulseLaucher • Jul 17 '25
I showed a professional 2D game engine programmer Pirate's lighting code and he said it's fit for purpose
I saw a video online talking about Pirate's lighting code, it just seemed off to me. I sent it to a professional 2D game dev and he told me the following:
The developer reviewed the code and found that the criticism in the video (claiming it's O(n^3)) is exaggerated and misleading. He mentioned that the code, written in GameMaker's GML, uses a pixel-by-pixel approach to avoid shaders, which is better for non-career programmers as it massively reduces complexity.
He also confirmed the time complexity is likely O(n) or O(x*y) (x = number of lights y = number of pixels) due to iterating over pixels and light sources, not O(n^3) as claimed. He pointed out that Pirate's method, while not perfectly optimized (e.g using case switches instead of clean math for directions and repeating diffusion steps), is a valid approach for a non-programmer game dev.
The video's suggested fixes, like using pre drawn light PNGs or surfaces, were wasteful in memory and not visually identical, offering no real performance gain. He also debunked the video's claims about redundant checks, noting they’re functionally intentional and O(1) with GameMaker’s collision grid.
Overall, he felt Pirate's code is decent for its purpose, and the video’s analysis and testing was wrong, as he had an "If true" statement which is a total blunder, running the code constantly, making his benchmarking completely wrong.
Edit:
If anyone has any questions for the dev, leave it in the comments and I'll forward it to him and I'll post his reply
View all comments
Show parent comment
2
u/TheMrFluffyPants Jul 17 '25
By your logic, you could also represent every pixel as a fixed total if you knew the resolution of the game. If the game were 128 x 128 pixels, you could argue it’s in constant time since you know the exact number of operations you’d need for 1 light source (16,384), but that’s not how algorithm analysis works.
The input for Thor’s algorithm isn’t number of pixels, it’s resolution. When you double the resolution, you aren’t just doubling either height or width. You’re doubling both of them, and the resulting number of operation quadruples.
Either way, whether it’s linear or quadratic, it doesn’t change the fact that Thor’s claims that this implementation is ‘highly performant’ is incredibly misleading. This is a brute force algorithm with no optimization for efficiency whatsoever.