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 7 ■ The Foundation of Game Play Loop: The <strong>Java</strong>FX Pulse System and the Game Processing Architecture<br />

As you can see, it only takes a fraction of a millisecond to initialize each of the event queues, including the pulse<br />

event, and all four ActionEvent EventHandler event processing queues. This is in keeping with our maximum game<br />

optimization approach, using static Scene Graph nodes and not doing anything inside the GamePlayLoop that will<br />

use up any more system resources (memory and processing cycles) than are absolutely necessary to accomplish the<br />

various tasks that you will be building up as you create your action-filled arcade game.<br />

Now that you have created and started your GamePlayLoop object, let’s take a look at the Threads Profiler!<br />

Again, scroll down in the Profiler tab, shown at the top left of Figure 7-17, and find the Threads icon, which is<br />

displayed at the top- left of Figure 7-18. NetBeans will ask you if you want to start the threads analysis tool; once you<br />

agree, it will open the Threads tab. As Figure 7-18 illlustrates, the pulse engine is running, and several pulse events are<br />

shown for Thread-6. Interestingly, once <strong>Java</strong>FX ascertains that the .handle() method is empty, the pulse event system<br />

does not continue to process this empty .handle() method and use unnecessary pulse events, indicating that the<br />

<strong>Java</strong>FX pulse event system has some modicum of intelligence.<br />

Figure 7-18. Click the Threads icon, seen at the left side of the screen, and open a Threads tab; AnimationTimer pulses<br />

can be observed on Thread-6<br />

InvinciBagel Diagram: Package, Classes, and Objects<br />

Next, let’s take a look at your current package, class, and object hierarchy, in the form of a diagram (see Figure 7-19),<br />

to see where you are in terms of creating your game engine. At the right of the diagram is the InvinciBagel class,<br />

which holds the Scene Graph, and Stage, Scene, and StackPane objects, which hold and display your splash screen UI<br />

design. At the left of the diagram is the GamePlayLoop class, which will contain the game processing logic calls and<br />

which gets declared and instantiated as a gamePlayLoop object in the InvinciBagel class but is not part of the Scene<br />

Graph hierarchy. Soon, you will start building the other functional areas displayed in the diagram so that you can<br />

control your sprites, detect collisions between the sprites, and simulate real-world forces of physics to make the game<br />

more realistic. You will see additions to this diagram as you progress through the book and create your <strong>Java</strong> 8 game.<br />

www.it-ebooks.info<br />

159

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

Saved successfully!

Ooh no, something went wrong!