Jump to content
  • Advertisement
Sign in to follow this  
Tarviathun

Dynamic Map Vision

This topic is 5006 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

NOTE: I'm not entirely sure if this is supposed to go into the Isometric forum, I'm not making an isometric RTS. However, if it isn't supposed to be here, please move it. Continuing my work on my RTS engine, I've come up with another challenge. How do I make dynamic map vision, a la Starcraft? I've researched this a bit and it looks like the best way is to use a modified A* algorithm. Does anyone have any suggestions on this? How would I darken the parts of the map that shouldn't be seen(eg haven't been explored by a unit) and then make them visible? Furthermore, how those then turn "inactive" when a unit leaves the active area? My method would be more along the lines of marking active/explored tiles based on unit movements that I'm using to find paths with A*. Active area would be defined by individual tile flags that mark a tile to updated in realtime vision. For inactive/explored area, I would mark(for buildings only) the last current image in their animation strain, which I would let remain until that area was marked again as active and the player could see. Does this sound like an acceptable method? It would seem to me that marking every single tile as "active" "inactive" or "non-visible" is a pretty costly way to do it, and an ugly hack. Any suggestions as to what way is best?

Share this post


Link to post
Share on other sites
Advertisement
Is your game 2d and based on a grid map? Even if it's 3d, if it's based on a grid map I would suggest something even simpler: just use a bounding circle of some specified radius around the unit. Any tiles within the circle can be flagged as visible. You could even use an inverse distance or distance squared function to make the tiles that are further away as dimmer than those closer (or maybe an inverse exponentional distance function if you only want the few tiles at the edge of the circle to be dimmer).

cheers
sam.

Share this post


Link to post
Share on other sites
Yes, it's grid based, rendered in 2D. Another thought that I had, would be such that I could subdivide the map into larger sections, say groups of 16x16 tiles, check for units, if there are none, do not add that section to the rendering queue. That way, I could easily eliminate large chunks of the map in the player's vision.

If there are units, use your vision radius idea. That, or I could simply light up that area, which would look bad.

Share this post


Link to post
Share on other sites
Just flag the tiles as visited or not for the basic exploration. You'll want to have a radius around units marked rather than just the tiles a unit occupies for this to look good. Have blackness (don't render there) if they aren't visited, or draw the tiles if they are flagged as visited (or observed to be more accurate). Once the whole map is revealed (if this happens), you can stop checking for this to save the processing power if it's important.

For fog of war (showing the tiles but not units, etc), you can keep a similar array of flags, but for each tile also store the time it was last seen. After a certain period of time, unflag the tile, and continue drawing it to screen, but stop updating it's state - just continue with the state from when it was lat flagged. It's also common to draw these tiles darker, or with a dark overlay.

Possibly not an optimal method, but it works - see what you can do.

//EDIT:
Quote:
Original post by Tarviathun
Yes, it's grid based, rendered in 2D. Another thought that I had, would be such that I could subdivide the map into larger sections, say groups of 16x16 tiles, check for units, if there are none, do not add that section to the rendering queue. That way, I could easily eliminate large chunks of the map in the player's vision.

If there are units, use your vision radius idea. That, or I could simply light up that area, which would look bad.


Yeah, that should work fine.

Share this post


Link to post
Share on other sites
Thanks for the recomendation. As far as resources, this is just a 2D game being rendered using OpenGL or DirectX(most likely DirectX because it's a bit more complete in certain areas), so you have hardware acceleration for a sprite game. Resources shouldn't be too much of a problem, even though I still don't like hacking my way around problems.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!