28.04.2019 Views

[JAVA][Beginning Java 8 Games Development]

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 6 ■ The Foundation of Game Design: The <strong>Java</strong>FX Scene Graph and the InvinciBagel Game Infrastructure<br />

<strong>Java</strong> Class Structure Design: Game Engine Support<br />

Next, let’s take a look at how the functional structure of the InvinciBagel game will need to be put together under the<br />

hood, so to speak, within your <strong>Java</strong> 8 game programming code, which is what this book is all about! There is really no<br />

correlation between what the front-facing UI screens look like and what the underlying programming logic looks like, as<br />

the majority of the programming code will go toward creating the game play experience on the game play screen. The<br />

game instructions and legal and credits screens will just be images (ImageView) and will either have the text embedded in<br />

the image (resulting in fewer Scene Graph nodes used) or composite a transparent TextView on top of the ImageView. The<br />

high scores screen will take a little bit of programming logic, which you will do toward the end of the game development,<br />

as the game logic has to be created and played for high scores to even be generated in the first place (see Chapter 17)!<br />

Figure 6-2 displays the primary functional area components required for the InvinciBagel game to be complete.<br />

The diagram shows an InvinciBagel Application subclass at the top of the hierarchy, creating the top level and the<br />

scene, and the Scene Graph contained below (or inside) it.<br />

Figure 6-2. Primary game functional classes and how they are implemented under the Scene and Scene Graph levels<br />

Below the InvinciBagel Scene object, which is actually created inside this InvinciBagel Application subclass, is the<br />

broader structural design for functional classes that you will need to code over the course of the remainder of the book.<br />

The engines (classes) shown in the figure will create your game functions, such as game engine (gameplay loop),<br />

logic engine (game play logic), sprite engine (actor management), actor engine (actor attributes), score engine<br />

(game-scoring logic), animation engine (animation logic), collision detection, and physics simulation. You will have<br />

to create all these <strong>Java</strong> class functions to fully implement a comprehensive, 2D game engine for the InvinciBagel game.<br />

The game engine, which I call the GamePlayLoop class, is the primary class that creates the AnimationTimer<br />

object that invoke the pulse events that continually process the gameplay loop. This loop, as you know, will call the<br />

.handle() method, which will in turn contain method calls, which will ultimately access the other classes that you<br />

will be creating to manage actors (sprite engine); move them around the screen (actor engine); detect any collisions<br />

(collision engine); apply the game logic after collisions have been detected (logic engine); and apply the forces of<br />

physics to provide realistic effects, such as gravity and acceleration, to the game play (physics engine).<br />

From Chapter 7 on, you will be building up these various engines, which will be used to create the game play<br />

experience. I will stratify chapter topics, based on each of these engines and what they need to do, so that everything is<br />

structured logically from a learning as well as coding perspective.<br />

www.it-ebooks.info<br />

125

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!