Game Development Reference
In-Depth Information
Once we have the Enemy and Projectile classes in place, the real challenge comes
in creating an auto-attack engine , so the game itself plays against the player, so that
we can create a single-player version of this game. We will do this by wiring the
Enemy.java class into the GamePlayLoop.java class, by calling the Enemy class .up-
date() method from the GamePlayLoop class .handle() method, which will allow us to
harness the JavaFX pulse timing engine for the iBeagle Enemy object. Once this is
done, we can code the Enemy object, and give it a life of its own, having it appear ran-
domly on the screen, and attack the InvinciBagel by shooting deadly bullets, or
scrumptious cream cheese balls.
We will build this auto-attack engine logically and gradually, first by making the
iBeagle Enemy appear on either side of the screen, and flip around to face the iBagel
character correctly. Then we will add programming logic that will animate the iBeagle
onto the screen, and then back off of the screen. Then we will make him shoot a bullet
or cream cheese ball, and then we will add some timing code in order to make his
movement far more realistic.
After that, we will add randomization to the appearance, locations, and movement,
so that the game player cannot tell where an iBeagle attack is going to come from.
After that we will add physics simulation so that the bullets and cream cheese balls are
affected by drag and gravity, all of which will make the game play more and more real-
istic, as the chapter progresses on, through the end of the topic!
I hope that you have enjoyed your learning experience during the topic, as much as
I have enjoyed writing it for you. Now let's get into making our game play more and
more challenging and professional, as we learn even more about Java 8 and JavaFX
classes and programming techniques.
Creating the Score UI Design: Text and
Font Objects
The first thing that we need to do to implement a display for our scoring engine is to
open the InvinciBagel.java tab in NetBeans, and add an integer variable to hold a nu-
meric score accumulation, and a Text UI element object, to display the score on the
bottom of the screen, alongside our other UI elements. The Text class in JavaFX is
used to work with text elements in your games, and even has its own javafx.scene.text
package, because text is an important element in applications. The integer data type al-
lows your game players to score well into the billions of points, so this should be ad-
equate for holding any magnitude of numeric score your game player can rack up. We
Search WWH ::




Custom Search