Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1
Chapter 8 ■ JavaFX 9 SCene Graph hierarChy: a Foundation For Java 9 Game deSiGn

This really isn’t so bad if you think about it, as these UI screens are all static and do not need to be
updated. That is, the UI elements contained in these Node objects are fixed and do not require any updating
using a pulse system, so you should still have 99 percent of the power of the JavaFX pulse engine left over
to process the JavaFXGame gameplay engine we’ll be coding during the book. You always need to remain
aware of how many SceneGraph Node objects you’re asking the pulse engine to process because if this
number gets to be too large, it will start to affect the game’s i3D performance. If the i3D game performance
suffers, gameplay won’t be smooth, which will affect your user experience (UX). The more Node objects we
keep static, the fewer have to be processed on each pulse.


Java Class Structure Design: Game Engine Support


Next let’s take a look at the functional structure of how the JavaFXGame code will need to be put together
“under the hood,” so to speak. This will be done using your Java 9 game programming code, which we
will be creating during this book. There is really no correlation between what the front-facing UI screens
look like and what your underlying programming logic will look like, as the majority of the programming
code for your game will always go toward creating the gameplay experience on the gameplay screen. The
game instruction and legal and credits screens will just be text (held in a TextFlow object) composited over
background imagery (held in an ImageView object). The scoreboard and high score screens will take a little
bit more programming logic, which we will do toward the end of the book since the game logic needs to be
created (and played) for a scoring engine and high scores to be able to be generated.
Figure 8-2 shows the primary functional game components that will be needed for your JavaFXGame to
be complete. The diagram shows a JavaFXGame.java Application subclass at the top of the hierarchy. This
creates the top-level JavaFXGame Scene object and the SceneGraph it contains, underneath or inside of, the
JavaFXGame application. These functional areas can either be implemented as methods or as classes. In this
book, we implement an i3D game using methods.


Underneath the JavaFXGame Scene object, which is created inside the JavaFXGame.java Application
subclass, is a broader structural design for functional Java 9 classes that you’ll need to code during the
remainder of the book. These engines (classes), shown in Figure 8-2, will create your game functions, such
as game engine (gameplay processing loop), logic engine (gameplay logic), sprite engine (3D geometry
management), actor engine (character’s attributes), score engine (game score logic), render engine
(real-time rendering), collision detection, and physics simulation. You will need to create all of these Java
methods in order to implement a comprehensive game engine for an i3D BoardGame.


Figure 8-2. Primary game engine functions, representing Java methods that you will need to code for your
game

Free download pdf