Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1
Chapter 20 ■ Coding gameplay: Set Up gameplay methodS and animated Camera View

Make sure you add the five if(picked == Q3S1) through if(picked == Q3S5) statements to the
OnMouseClick event handling in createSceneProcessing() to connect the new methods to your ever-growing
gameplay experience.
As shown in Figure 20-14, use the Run ➤ Project work process and test the code related to quadrant 3
to make sure that the quadrant and content images are all appearing correctly and that they look clear and
professional.


Finally, let’s create the last five setupQSgameplay() methods, shown in Figure 20-15, which will look
like this:


private void setupQ4S1gameplay() {
if (pickS16 == 0) {diffuse24 = new Image("gamequad4s1fame0.png", 512, 512, true, true, true);
Shader24.setDiffuseMap(diffuse24); }
if (pickS16 == 1) {diffuse24 = new Image("gamequad4s1fame1.png", 512, 512, true, true, true);
Shader24.setDiffuseMap(diffuse24); }
if (pickS16 == 2) {diffuse24 = new Image("gamequad4s1fame2.png", 512, 512, true, true, true);
Shader24.setDiffuseMap(diffuse24); }
}
private void setupQ4S2gameplay() {
if (pickS17 == 0) {diffuse24 = new Image("gamequad4s2fame0.png", 512, 512, true, true, true);
Shader24.setDiffuseMap(diffuse24); }
if (pickS17 == 1) {diffuse24 = new Image("gamequad4s2fame1.png", 512, 512, true, true, true);
Shader24.setDiffuseMap(diffuse24); }
if (pickS17 == 2) {diffuse24 = new Image("gamequad4s2fame2.png", 512, 512, true, true, true);
Shader24.setDiffuseMap(diffuse24); }
}


Figure 20-14. Use a Run ➤ Project work process to test; make sure each square populates the quadrant with
the correct image

Free download pdf