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-58. Add an if-else structure after the bulletType, randomLocation, and iBagelLocation to locate by bulletType<br />

Adding Gravity to the Bullets: Intro to Game Physics<br />

Since physics calculations tend to use fractional numbers rather than integers, we need to pull the randomOffset out of<br />

the compound integer declaration and make it a double randomOffset; declaration, as seen in Figure 17-59. Also, you’ll<br />

need to declare double variables for bulletGravity and cheeseGravity, and set them equal to 0.2 and 0.1 values.<br />

Figure 17-59. Declaring bulletGravity and cheeseGravity double variables, and converting randomOffset to a double<br />

www.it-ebooks.info<br />

451

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

Saved successfully!

Ooh no, something went wrong!