Pro Java 9 Games Development Leveraging the JavaFX APIs

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

Note that I am showing only half of the statements in Figure 19-18 because my HD display could not show
all of them and still show (contain) the NetBeans IDE UI. It’s time to upgrade to a 4K UHD display I guess!
Use a Run ➤ Project work process, seen in Figure 19-19, to test the code we’ve developed so far thoroughly.
It works consistently.


We’ve added some more of the core gameplay functionality that will be needed to control and
randomize your game board square content and the gameplay during this chapter, and we’ve set up your
Java code so that it is easy to add more content by simply incrementing random.nextInt(bounds) (bound
variable) every time you add a of square content imagery. This makes our game easily extensible, which is
important for the professional Java 9 game design.
You’ll also need to add if() statements (or, more likely, change to using Java case statements if you
have more than two or three content options to select from) to add the code logic that allows the game to
randomly select from your different image options for a given square. We’ll be enhancing this code in the
next chapter as we continue to refine the populateQuadrant() methods with their own (nondummy) content
and add the ability for the players to click a game square and populate the selected content into the current
quadrant using the quadrant texture maps that we developed already during Chapter 17. At that point, we
will be ready to add gameplay directly relating to a game square content selection, challenging our game
player’s body of knowledge and educating them in the process.
Notice that we are still at less than 700 lines of Java code with 17 methods (an average of 39 per
method), as you can see at the bottom of NetBeans in Figure 19-18 (the end of the class was line 655, before I
added the last 20 Java statements, so, basically we’re at 675).


Figure 19-19. As you see in the Output Pane, subsequent random spinner clicks now populate the correct
quadrant

Free download pdf