Game Development Reference
In-Depth Information
if (keyCode == KeyEvent.KEYCODE_M && loaded) {
if (sound) {
crashSound.stop();
explosionSound.stop();
fireSound.stop();
missileSound.stop();
saucerSound.stop();
thrustersSound.stop();
warpSound.stop();
} else {
if (misslePlaying && !paused)
missileSound.loop();
if (saucerPlaying && !paused)
saucerSound.loop();
if (thrustersPlaying && !paused)
thrustersSound.loop();
}
sound = !sound;
}
/**
* 'S' key: start the game, if not already in progress.
*/
if (keyCode == KeyEvent.KEYCODE_S && loaded && !playing) {
initGame();
}
/**
* 'E' Exit game
*/
if (keyCode == KeyEvent.KEYCODE_E ) {
stopUpdateTimer();
releaseSounds();
System.exit(0); // Ouch!
}
}
Our arcade game is now complete, and we can run it in the emulator.
Testing Asteroids on the Emulator
Let's fire the emulator and play some Asteroids! Here is how:
1.
Create a new launch configuration. From the Eclipse main menu,
click Run Run Configurations.
2.
Enter a configuration name, Asteroids.
3.
Select the project, ch04.Asteroids.
Search WWH ::




Custom Search