Line of sight

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
Korosu
Prole
Posts: 11
Joined: Tue Oct 21, 2014 11:10 pm

Line of sight

Post by Korosu »

I have a line of sight algorithm, however when checking the players (x,y) and the enemys (x,y) against the table of blocks it only returns nil (no LoS) When all blocks are in the way of the LoS, eg:

P - Player
W - Wall
E - Enemy

P--------W-----E----W (LoS = true)

P-------E-----W-----W (LoS = true)

P ----------W----W-----E (LoS = false)


I've included the love file,
wasd to move, green background = no LoS
Attachments
LoS.love
(1.48 KiB) Downloaded 186 times
"It just needs a few small tweaks", 5 hours pass, "Lets just start again"
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Line of sight

Post by Robin »

Fixed it for you. The problem was that you effectively only checked the last block, because all earlier checks are undone.
Attachments
LoS.love
(1.46 KiB) Downloaded 192 times
Help us help you: attach a .love.
Korosu
Prole
Posts: 11
Joined: Tue Oct 21, 2014 11:10 pm

Re: Line of sight

Post by Korosu »

Thanks
"It just needs a few small tweaks", 5 hours pass, "Lets just start again"
Post Reply

Who is online

Users browsing this forum: No registered users and 80 guests