0
\$\begingroup\$

I am implementing line-of-sight into a strategy game I am developing, and I would like to shade the map darker outside of the LoS of the player and their structures (fog of war). The trick is, this is a location-based strategy game for android using the Google Maps API.

Now, I know how I would draw just one circle for the LoS: by drawing a dark circle centered on the antipode of the play or structure in question. The only problem is I could only do this for one structure at a time, as the shade would essentially overlap and override any other LoS circles. This is a position that I can ultimately settle with if there is no other option.

What I would rather do is essentially shade the map except for the radii around the player and any of their structures. See the images below for an example of what I am talking about. The red dots are the structures, the white circles are the Line-of-Sight, and the black area is of course the shaded remainder of the map:

Fog of war illustration

\$\endgroup\$
4
  • \$\begingroup\$ You may want to review past Q&A with the fog-of-war tag, as this is a fairly common confusion for new developers who aren't yet familiarized with depth/stencil buffers or drawing to off-screen render targets as temporary intermediates before compositing the final image. \$\endgroup\$ Commented May 29, 2022 at 14:39
  • \$\begingroup\$ Thank you for the link. Looking over these questions, I don't see any which pertain to location based games on the google maps api, which I believe is what I specifically need. \$\endgroup\$ Commented May 29, 2022 at 17:06
  • \$\begingroup\$ That's what goes under the shadow. Drawing the shadow over top does not depend on what's underneath it. \$\endgroup\$ Commented May 29, 2022 at 17:14
  • \$\begingroup\$ Interesting. I'm not an expert on this stuff by any means, an amateur really. Currently all the things rendered on the map are rendered as map markers. There is a way for me to render other things over top of the map view without them being map markers or part of the map? \$\endgroup\$ Commented May 29, 2022 at 17:37

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.