Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / check for line of site in a grid?

Author
Message
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 15th May 2011 18:09
Hey guys

Here's the scenario:



I have a grid (203*203), and this grid is stored in an array map(x,y). If a block is placed, the array will return a 1, otherwise a 0 is returned (for example, there is a red block at 87,4, then map(87,4)=1). The player objects are those circles. How would I go about checking if the circles are in direct line of site or not?

Thanks,

TheComet

Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 15th May 2011 18:50
Following a ray connecting two circles, you check the array's content. If there is at least one block which is a wall, there are not in sight, very simple.

Or you know the theoretics but not the technique to do it?

-In.Dev.X: A unique heavy story based shoot'em ~25%
-CoreFleet: An underground commander unit based RTS ~15%
-TailsVSEggman: An Sonic themed RTS under development for idea presentation to Sega ~15%
Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 15th May 2011 19:00 Edited at: 15th May 2011 19:01
Just googled "line grid intersection"

Got this:
http://playtechs.blogspot.com/2007/03/raytracing-on-grid.html

[b]
Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 15th May 2011 22:29
I saw something in code snippets that might be 100% relevant:
http://forum.thegamecreators.com/?m=forum_view&t=178579&b=6


Tell me if there's a broken link to images in a thread I post, and I'll fix 'em.
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 16th May 2011 14:47
Thanks guys!

TheComet

Login to post a reply

Server time is: 2026-07-11 06:06:56
Your offset time is: 2026-07-11 06:06:56