Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1

© Wallace Jackson 2017 185
W. Jackson, Pro Java 9 Games Development, https://doi.org/10.1007/978-1-4842-0973-8_8


CHAPTER 8


JavaFX 9 Scene Graph


Hierarchy: A Foundation for


Java 9 Game Design


Let’s build on our newfound knowledge of JavaFX, game design, multimedia, and Java that we learned about
in the previous chapters here in Chapter 8 by starting to design the infrastructure of our i3D JavaFXGame
game, from both a User Interface and User Experience standpoint and an “under the hood” game
engine, 3D sprite engine, collision engine, and physics engine standpoint. We will keep optimization
in mind, as we must do during the rest of the book, so that we don’t get a Scene Graph that is so extensive
or complicated that the pulse system cannot update everything efficiently. This means keeping primary
game UI screens (StackPane Node) to a minimum (four or five) to leave most processing power for the
3D game rendering (Group Node) and making sure the Media Player (digital audio or digital video) uses
its own thread, if this type of media is used at all. (Audio and especially video is very data heavy and can
be very processing intensive.) You will also need to make sure that the functional “engines” that drive the
game are all coded modularly and logically, use their own classes, and utilize the proper Java programming
conventions, structures, methods, variables, constants, and modifiers that you learned about in Chapter 5.
It will be a massive undertaking and will take hundreds of pages to implement, starting with this chapter,
now that I have made sure you are all on point with your knowledge of Java, JavaFX, NetBeans, 2D, and 3D
new media concepts.
The first thing that I will cover is a top-level, front-facing user interface screen design, which your game
will offer to the user when launching the Java application. This will include the BoardGame “branding”
splash screen that a user sees when launching the application. This screen will have Button controls on
one side that access information screens containing instructions, credits, legal disclaimers, and the like.
These UI screens, which we want to minimize in number, will be StackPane Node layers. A StackPane
object is designed to contain stacked image (compositing) layers. These game support screens will contain
information that a user needs to know in order to play the game effectively. This includes text-based
information, such as game instructions, credits, legal disclaimers, and a high score screen. We will include
legal disclaimers to keep the legal department happy and will feature a credits screen highlighting the
contributions of programmers and new media artisans who worked on creating the game and game assets.
The next level down of this BoardGame design foundation that we will conceptualize during this
chapter is the under the hood, back-facing game engine component Java class design aspects for the
BoardGame. These will be unseen by the game user but are still very important. They might include a
GamePlay Engine to control gameplay updates to the game using JavaFX pulse, a 3D Sprites Engine to
manage 3D game sprites for the game, a Collision Engine that detects and responds when any collision has
occurred between two sprites, a Physics Engine that will apply force and similar physics simulations to the
gameplay so the 3D sprites accelerate and bounce realistically, and finally the 3D Actor Engine that will

Free download pdf