Qbasicnews.com

Full Version: AI Question
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm making enemies in my game have primitive AI, so that they follow you.
But for some reason (and I've debugged and debugged and debugged) they never move.
There are very many important aspects of my code that relate to the actual moveEnemies subroutine, so I've posted my code here:
http://www.thegeekery.org/MAIN.zip
The problem is in the moveEnemies procedure, I believe. For some reason, it isn't moving my the enemies.
Although this could just be a stupid error on my part, but you can never tell. :wink:
I think theres something wrong with numEnemies, it's set to zero, so the for loop to move them never executes. I'll look into it further...
numEnemies is set to 8 after the map loads. The problem is that the moveEnemies sub has a default data type of single, while the rest of your program is integer. Removing the "DEFSNG A-Z" line above the moveEnemies sub will fix your problem.
I tried what you said Plasma, and it didnt work, at least for me.

Tracing numEnemies through the program by PRINTing at various stages:

Before setup, everything at default, 0
After map loads, set at 16
Exiting sub, set at 16
In main method, before moveEnemies, set at 16
Inside moveEnemies, its 0 again.
Also trying to access the map gives a out of bounds error

It would appear to me the globals are not accessible in that sub, but I cant see why.. yet. My QB is rather rusty... (squeak squeak)
I got it working... I made a change at the start that messed everything up :oops:

I really am off-form with my QB'ing :barf: