Page 1 of 1

Best way to convert a circle into a 'perspective'?

Posted: Mon Aug 14, 2017 2:38 am
by ksjk1998
I've been having this perplexing situation regarding the LOVE game engine. One that involves a game I'm working on. I want to create a circle around my character. That is not the problem. Rather, the problem occurs with what I want that circle to do. I want this circle, AND the points after it to disappear when the area hits an object, specifically one that is solid. Think of it in the perspective of a top-town stealth game. Where the visibility range of an enemy guard gets cut off by an object. That is the kind of circle that I want. I have a snippet of code that creates a pseudo-circle (it has its flaws)

Code: Select all

 for i=0,radius*4,1 do
    love.graphics.line( playerX, playerY, math.sin(math.pi(i/radius/2))*radius + playerX, math.cos(math.pi*(i/attkRad/2))*radius + playerY)
 end  
that answers a part of the problem. What I need to do now is adjust the lines length so it does not intersect with an object in the foreground. In this regard, I have no idea what function to use that gives me a clue on how to do this. any other solution to this problem would no doubt be helpful.

Thank you in advance.

Re: Best way to convert a circle into a 'perspective'?

Posted: Tue Aug 15, 2017 12:14 am
by alloyed
This is called line-of-sight, or sometimes field-of-view.
Here's an article describing a few possible approaches, although it isn't the only approach out there:
http://www.redblobgames.com/articles/visibility/

Re: Best way to convert a circle into a 'perspective'?

Posted: Tue Aug 15, 2017 2:46 am
by ksjk1998
alloyed wrote: Tue Aug 15, 2017 12:14 am This is called line-of-sight, or sometimes field-of-view.
Here's an article describing a few possible approaches, although it isn't the only approach out there:
http://www.redblobgames.com/articles/visibility/
thank you for the link. Definitely noted, but I'm honestly stumped as to what function can detect these points as stated in the article