Sign in to follow this  
iliak

Line of view in a 2d maze (RPG)

Recommended Posts

iliak    278
Hi I'm making a clone of Eye of the Beholder and I'm stuck when I need to detect if the team (the player position ie) can see a given location (or for example, does a monster can see the team). The maze is a simple 2d grid with 1 = wall and 0 = empty place. Team and monsters can't see through walls. My first attempt was to use bresenham algorithm but with this, team virtualy can see in through wall in diagonal. Do you have any suggestion or better idea ?

Share this post


Link to post
Share on other sites
jyk    2094
Quote:
Original post by iliak
Hi

I'm making a clone of Eye of the Beholder and I'm stuck when I need to detect if the team (the player position ie) can see a given location (or for example, does a monster can see the team). The maze is a simple 2d grid with 1 = wall and 0 = empty place. Team and monsters can't see through walls. My first attempt was to use bresenham algorithm but with this, team virtualy can see in through wall in diagonal.

Do you have any suggestion or better idea ?
Try doing a search for '3D-DDA', '3DDDA', '2D-DDA', and '2DDDA'. This algorithm is a pretty good choice for line-of-sight queries.

Another option would be simple SAT-based line-segment vs. axis-aligned-box queries, perhaps with a quadtree- or grid-based broad phase to speed things up.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this