Jump to content
  • Advertisement
Sign in to follow this  
schlooby

Determining what things to and to not draw

This topic is 5008 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

This one I can't seem to figure out. My game is a 3d game, and the map is stored in a 2D array like this:
.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0
.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0
.0#2#2#2.0#2#2#2.0#2.0.0.0.0.0
.0#2.0.0.0.0#2#2.0#2.0.0.0.0.0
.0#2.0.0.0.0#2#2.0#2.0.0.0.0.0
.0#2#2hThT#2#2#2.0#2.0.0.0.0.0
.0.0.0.0.0.0.0#2.0#2#2.0.0.0.0
.0.0.0.0.0.0.0#2.0#2.0.0.0.0.0
#2#2#2hThT#2#2#2.0#2.0.0.0.0.0
.0.0.0.0.0.0.0.0.0#2.0.0.0.0.0
.0#2#2#2#2#2#2#2#2#2.0.0#2#2#2
.0#2.0.0.0.0.0.0.0.0.0.0.0.0.0
.0#2.0.0.0.0.0.0.0.0.0.0.0.0.0
.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0
.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1
What I want to be able to to is check if I can see a certain square at a given time to determine if I could see it, for example, what I could see would be like this [Player is the XX, each cell is two characters]
.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0
.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0
                  #2.0.0XX.0.0
                  #2.0.0.0.0.0
                  #2.0.0.0.0.0
                  #2.0.0.0.0.0
                  #2#2.0.0.0.0
                    .0.0.0.0.0
                  #2.0.0.0.0.0
                  #2.0.0.0.0.0
                  #2.0.0#2#2#2
                  .0.0.0      
                  .0.0.0      
                .0.0.0.0      
                .1.1.1.1      
My question is how would I determine if I could see a cell? Here is a screenshot of the game to clear it up a little bit http://et.ath.cx/chogblasters4.jpg I want to cover the stuff that the user won't see so it won't bog down performance, and just draw the stuff that matters. Thanks, schloob.

Share this post


Link to post
Share on other sites
Advertisement
I'm finding that article everywhere, but I don't see whats so good about it... Where's the algorithm in it? :\ Did I miss it?

Why does everything have to be so complicated

Does anyone have an algorithm that I can have -- or you could explain to me how it works -- for calculating the line of sight :\?

Thanks again, schloob :D

Share this post


Link to post
Share on other sites
There is a method called ray-casting that could probably be adapted to do what you want. Basically you compute the trajectories of 2-d lines cast from the players location to find where they intersect walls on the map grid.

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!