Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1
Chapter 19 ■ Game Content enGine: ai LoGiC with random Content SeLeCtion methodS

Let’s use a Run ➤ Project work process and see whether the Output Pane is now telling us what
quadrant the spin is going to land on. This is information that you will eventually want to hide from the
players so that their “destination” quadrant is not revealed before the game board stops spinning, which
would ruin the anticipation and gameplay fun.
What I did to create the screenshot in Figure 19-4 was to position (and resize) the NetBeans 9 Output
Pane behind (and to the left of ) the game window so that the println output of the angle delta (remainder)
is visible. While I am testing the i3D spinner UI and game board spin cycles, this println output notification
triggers to make sure that they now land randomly and accurately on different colored quadrants for random
gameplay (like a roll of the dice, only a spin of the board).
A calculated spin angle offset shows up right when you click the spinner (computers are fast these days),
so you know in advance what quadrant the game board is going to land on. For now, we are just trying to
get the game board to land on a different quadrant with each random spin and to see what angle values are
ending up inside of the quadrantLanding variable so we can test for these in our future code. We also want
to spin a bunch of times to make sure that these quadrant angle offset values are the same exact four integer
numbers every time and that they do not vary, as we only want to test for four quadrantLanding angle offset
values in our code. Any other values in this variable will “break” this code. Fortunately, everything involving
quadrants and rotation involves even numbers!
As far as which angle offset value belongs to each color quadrant, we have not tested and refined the
Java code to that point yet. This is part of what we are going to be doing in this chapter, to make sure we
know exactly what is going on between our Java 9 game code and the i3D game board spin quadrant rotation
landing visual result.


Figure 19-3. Add a calculateQuadrantLanding() method and code method body and call
calculateQuadrantLanding() at the end of each MouseEvent

Free download pdf