I've been glancing at this every once in a while for the past few months, but all I've accomplished is to find more problems with my methods. I'm attempting to create an algorithm that functions as a "sight detection system"; if the player steps within a four tile radius of this moving event, a process is activated. Here's what I've used:
This doesn't work very well. For one thing, the Lich can see as far behind it as it can ahead, which would take some complex Conditional Branches for checking direction which is confusing enough, in additon to the fact that I need to calculate that as a semi-circle rather than half a square, and that just seems impossible to me. D:
Any suggestions for applying the changes I mentioned above into this algorithm? Thanks!
Code:
Player X = Player's Map X
Player Y = Player's Map Y
Lich X = This Event's Map X
Lich Y = This Event's Map Y
Distance X = Player X
Distance Y = Player Y
Distance X -= Lich X
Distance Y -= Lich Y
If Distance X >= -4
If Distance X <= 4
If Distance Y >= -4
If Distance Y <=4
Run processing etc. etc.
End
End
End
End
This doesn't work very well. For one thing, the Lich can see as far behind it as it can ahead, which would take some complex Conditional Branches for checking direction which is confusing enough, in additon to the fact that I need to calculate that as a semi-circle rather than half a square, and that just seems impossible to me. D:
Any suggestions for applying the changes I mentioned above into this algorithm? Thanks!