Hello, I hope this is the right category.
I wanted to implement something like a fog of war for my 2d shooter game. I am using Java 2D graphics.
Currently, what I do is go over each pixel of the screen and compute whether the distance from that pixel to the player is more than some number (200 for example). Then, I just do a & bit operation with a mask which has all of its even bits on. This makes the pixel look gray.
However, there is lag. This is mainly because I go over each pixel. Since there are 800x600 pixels, the computation is quite slow. What do you think? How can I implement something like "fog of war" or "line of sight"?
I was thinking of trying to improve the other computations in the game so that it is left more time for this part of the game. For example, currently I check all objects for a collision. I can reduce it by using a binary space tree.
What do you think?
P.S. I cannot switch to Opengl at this point.