Game Development Reference
In-Depth Information
if (photonIndex >= Constants.MAX_SHOTS)
photonIndex = 0;
photons[photonIndex].active = true;
photons[photonIndex].x = ship.x;
photons[photonIndex].y = ship.y;
photons[photonIndex].deltaX = 2 * Constants.MAX_ROCK_SPEED
* -Math.sin(ship.angle);
photons[photonIndex].deltaY = 2 * Constants.MAX_ROCK_SPEED
* Math.cos(ship.angle);
}
/**
* 'H' key: warp ship into hyperspace by moving to a random location and
* starting counter. Note: keys are case independent
*/
if (keyCode == KeyEvent.KEYCODE_H && ship.active && hyperCounter <= 0) {
ship.x = (int) (Math.random() * getWidth());
ship.y = (int) (Math.random() * getHeight());
hyperCounter = Constants.HYPER_COUNT;
if (sound & !paused)
warpSound.play();
}
/**
* 'P' key: toggle pause mode and start or stop any active looping sound
* clips.
*/
if (keyCode == KeyEvent.KEYCODE_P) {
if (paused) {
if (sound && misslePlaying)
missileSound.loop();
if (sound && saucerPlaying)
saucerSound.loop();
if (sound && thrustersPlaying)
thrustersSound.loop();
} else {
if (misslePlaying)
missileSound.stop();
if (saucerPlaying)
saucerSound.stop();
if (thrustersPlaying)
thrustersSound.stop();
}
paused = !paused;
}
/**
* 'M' key: toggle sound on or off and stop any looping sound clips.
*/
Search WWH ::




Custom Search