Pro Java 9 Games Development Leveraging the JavaFX APIs

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

Let’s copy and paste another five method bodies and create the setupQSgameplay() methods
for quadrant 3. Make sure that your image asset names match up with the names you are using for
populateQuadrantThree(). The Java code should look like the following method bodies, which are also
shown in yellow in Figure 20-12:


private void setupQ3S1gameplay() {
if (pickS11 == 0) {diffuse23 = new Image("gamequad3s1rock0.png", 512, 512, true, true, true);
Shader23.setDiffuseMap(diffuse23); }
if (pickS11 == 1) {diffuse23 = new Image("gamequad3s1rock1.png", 512, 512, true, true, true);
Shader23.setDiffuseMap(diffuse23); }
if (pickS11 == 2) {diffuse23 = new Image("gamequad3s1rock2.png", 512, 512, true, true, true);
Shader23.setDiffuseMap(diffuse23); }
}
private void setupQ3S2gameplay() {
if (pickS12 == 0) {diffuse23 = new Image("gamequad3s2rock0.png", 512, 512, true, true, true);
Shader23.setDiffuseMap(diffuse23); }
if (pickS12 == 1) {diffuse23 = new Image("gamequad3s2rock1.png", 512, 512, true, true, true);
Shader23.setDiffuseMap(diffuse23); }
if (pickS12 == 2) {diffuse23 = new Image("gamequad3s2rock2.png", 512, 512, true, true, true);
Shader23.setDiffuseMap(diffuse23); }
}
private void setupQ3S3gameplay() {
if (pickS13 == 0) {diffuse23 = new Image("gamequad3s3rock0.png", 512, 512, true, true, true);
Shader23.setDiffuseMap(diffuse23); }
if (pickS13 == 1) {diffuse23 = new Image("gamequad3s3rock1.png", 512, 512, true, true, true);
Shader23.setDiffuseMap(diffuse23); }


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

Free download pdf