28.04.2019 Views

[JAVA][Beginning Java 8 Games Development]

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 17 ■ Enhancing Game Play: Creating a Scoring Engine, Adding Treasure and an Enemy Auto-Attack Engine<br />

Figure 17-10. Add .playiSound() method calls in each if() statement body to play different audio for each type<br />

Now we have even more game play interaction in place, as the scoreboard will instantly update correctly on<br />

each collision, and will play an audioClip at the same time, to indicate that a collision has been detected, the type of<br />

collision that has occurred (good or bad), and that the scoreboard has been updated, since after all, this programming<br />

logic is contained in the scoringEngine() method and thus should pertain to the act or scoring in some way or another.<br />

After we test this conditional if() programming logic and make sure that everything works as anticipated, we<br />

can take a look at how to add optimization into this .scoringEngine() method, and then we will be ready to add some<br />

more Actor types, such as the Treasure.java class, which we will be adding next. After that, we can add some enemies<br />

(adversaries) to the InvinciBagel game, as we continue to add features that make our game play more fun and exciting<br />

during the course of this chapter.<br />

Test the game, using the Run ➤ Project work process. As you can see in Figure 17-11, the scoreboard works!<br />

www.it-ebooks.info<br />

401

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!