Game Development Reference
In-Depth Information
Figure 17-56 . Add an attackFrequency statement incorporating a .nextInt(bounds) method in if (onScreen &&
launchIt)
As you can see when you use the Run Project work process, you no longer can
calculate when any given Enemy attack will commence! Let's make the auto-attack en-
gine more intelligent, by telling it where the InvinciBagel character is located (Y co-
ordinate) on the screen, so that the auto-attack engine can more effectively target him!
Targeting the InvinciBagel: Adding Enemy Artificial
Intelligence
The next thing that we should do to make game play more challenging is tell the auto-
attack engine where the iBagel is located on the screen, an artificial intelligence gather-
ing mission, made easier because we control all of the Java code! To do this, instead of
using the randomLocation random Y screen height location value, we will create a
variable that will hold the InvinciBagel Y screen height location value, giving the
Enemy inside information regarding where the iBagel object is on the screen. This is
done using the iY attribute of the iBagel Hero object, which we access using the
 
Search WWH ::




Custom Search