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-44. Add a pauseCounter variable to create a timer, creating a one-second delay, so Enemy doesn't bounce<br />

Shoot the Bullet: Pulling the Trigger Using the launchIt Variable<br />

Inside of each of your if(takeSides) and if(!takeSides) conditional if structures, modify the if(onScreen) structure to<br />

be an if(onScreen && launchIt) structure instead, and then add a launchit = false; statement into the else<br />

portion of this modified structure. The <strong>Java</strong> code for the new if() structure is shown in Figure 17-45, and looks like<br />

the following:<br />

if(onScreen && launchIt) {<br />

destination = 700;<br />

if(spriteMoveR

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

Saved successfully!

Ooh no, something went wrong!