Pro Java 9 Games Development Leveraging the JavaFX APIs

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

As you can see in Figure 19-14, when I selected Run ➤ Project to test the code, the quadrant and content
are correct, even though the rotation of the Quadrant 1 content is not correct for the other quadrants.


Next, let’s finish creating the populateQuadrantThree() and populateQuadrantFour() methods so that
we can see digital image (visual) content in all of the game board squares as we test the game board spin and
quadrant landing code; as you have seen, there is still game content design work to be done regarding the
orientation of the game board square images depending on what quadrant they are used in.
Copy and paste your populateQuadrantTwo() (or your populateQuadrantOne() content) code structure
into the empty populateQuadrantThree() method body and change the pickS, diffuse, and Shader values to
range from 11 to 15. Leave the Image object references alone for now, as you have only one set of quadrant
Image assets created.
Copy and paste your populateQuadrantTwo() (or your populateQuadrantOne() content) code structure
into the empty populateQuadrantFour() method body and change the pickS, diffuse, and Shader values to
range from 16 to 20. Leave the Image object references alone for now, as you have only one set of quadrant
Image assets created.
Figure 19-15 shows the Java if() constructs for populateQuadrantFour(), which look like this Java code:


int pickS16 = random.nextInt(3);
if (pickS16 == 0){diffuse16 = new Image("/gamesquare1bird0.png", 256, 256, true, true, true);}
if (pickS16 == 1){diffuse16 = new Image("/gamesquare1bird1.png", 256, 256, true, true, true);}
if (pickS16 == 2){diffuse16 = new Image("/gamesquare1bird2.png", 256, 256, true, true, true);}
Shader16.setDiffuseMap(diffuse16);


Figure 19-14. The new angle offset evaluation code now provides the correct game board quadrant landing
position

Free download pdf