Pro Java 9 Games Development Leveraging the JavaFX APIs

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

Finally, let’s use a Run ➤ Project work process to test the code. As you can see in Figure 20-23, it works
great, and we have some nice areas on the left and right sides of the screen to overlay our 2D user interface
areas, which we will be creating over the next couple of chapters to finish up the i3D board game.


In the next few chapters, we will continue to add not only digital audio sound effects but also the
questions and answers that will challenge our players. We’ll also add a scoring engine, which will track their
success identifying content.


Summary


In this twentieth chapter, we learned more about how to complete our implementation of the random
selection of game board square content. We implemented the onMouseEvent handling code that puts the
quadrant texture maps into place once the content has been selected by the player as a game board square
is clicked. We also implemented camera animation code, which changes the view of the game board once
the game board square is selected so that the quadrant has a larger image displayed. This essentially puts us
into a position to start coding the individual square (and quadrant, once the square is selected) gameplay,
where a visual question regarding the content is answered and scored, which we will be creating in Chapters
21 and 22. Much of this code will go into the setupQSgameplay() methods for each square, for which we put
a foundation in place in this chapter. After that, we will look at creating a scoring engine, digital audio effects
to enhance the gameplay, and maybe a few more Animation objects. This will make the gameplay even
more interactive 3D and to add even more professionalism.
This was one of your heavy coding chapters (as will be the next chapter). You constructed 20 custom
methods, setupQ1S1gameplay() through setupQ4S5gameplay(), and you placed conditional if() structures
pointing to these in your OnMouseClick() event handling infrastructure. You also cross-checked imaging
assets between all of your populateQuadrant() methods and, finally, tested all of this code together to make
sure it works properly.


Figure 20-23. The cameraAnimIn Animation object now works as expected, removing the spinner

Free download pdf