Hello all,
Let me set an introduction to the problem I am facing.
I have been experimenting with in-game a.i. for a month or so, and have come up with a few starting techniques, which work...partially. What I have written, is a 2D program using circles and lines, which includes a Player Character and what will be a Non-Player Character.
I have been experimenting on creating view limits and boundaries of the a.i., where it can only see so far out, and so far to it's sides. First, I judge the distance in between the Player Character and the Non-Player Character. If their distance apart is within 300 units then I calculate if the Player Character is within -45o and +45o of the Non-Player Character's current angle of direction, thus creating a limit to how far to each side the Non-Player Character can see. If so, the "inboundary" variable is set to 1 and "In Boundaries" is printed to the screen.
The problem is that if the Non-Player Character's current angle of direction is between the angles of 315o to 0o and 0o to 45o, though mathematically within these angles the Non-Player Character should detect the Player Character, it does not. In between 315o and 45o is the almighty 0o. I know this the problem, but why is it the problem, and how do you theorize it can be fixed?
Since I use #Include files which cradle my functions, I have attached a ZIP file of all my source code to run this program, which does not include any media and is only 319KB(compressed) in size. The file "driver.dba" is the one you need to execute to run the program. The file "ai_main.dba" is where the functions for Player Character detection are held. When the program is in "run-time", statistics are printed to the screen to help you help me figure this out. The controls are printed to the screen. Thank you, whoever takes their time to help me.
+NanoBrain+