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
Line of sight
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Line of sight
- Attachments
-
- LoS.love
- (1.48 KiB) Downloaded 198 times
"It just needs a few small tweaks", 5 hours pass, "Lets just start again"
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Line of sight
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 199 times
Help us help you: attach a .love.
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 5 guests