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

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
ksjk1998
Prole
Posts: 2
Joined: Mon Aug 14, 2017 2:13 am

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

Post 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.
alloyed
Citizen
Posts: 80
Joined: Thu May 28, 2015 8:45 pm
Contact:

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

Post 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/
ksjk1998
Prole
Posts: 2
Joined: Mon Aug 14, 2017 2:13 am

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

Post 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
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 50 guests