Determining what things to and to not draw

Started by
3 comments, last by unfinished 19 years, 4 months ago
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.
Advertisement
Maybe this will help: Line Of Sight Algorithm.
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
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.
This looks quite helpfull I found itabout a year ago


http://www.sbdev.pwp.blueyonder.co.uk/ray.htm

This topic is closed to new replies.

Advertisement