HTML and CSS Reference
In-Depth Information
tempSound.volume = volume;;
soundPool.push({name:sound, element:tempSound, type:audioType, played:true});
Go ahead and try this code. It is CH7EX9.html in the code distribution, or you can type
in the program listing.
Other stuff you could do to improve the game
Since the next couple chapters introduce game concepts, we really shouldn't go much
further with Space Raiders . Still, if you were going to finish this game, these are the
things you might consider doing:
1. Add a score.
2. Increase the aliens' speed on each new level.
3. Collision-detect the aliens and the player.
4. Make an object pool for missiles and aliens.
5. Slow down firing with a wait() state or frame counter.
6. Add explosions.
7. Include a title sequence, level sequence, and end game sequence.
8. Add a looping soundtrack.
The final code for Space Raiders
Example 7-6 shows the final code for the Space Raiders game ( CH7EX9.html ).
Example 7-6. Space Raiders with optimized dynamic network sound and state loader
<!doctype html>
<html lang="en">
<meta charset="UTF-8">
<title>CH7EX9: Space Raiders With Optimized Dynamic Network Sound And State Loader</title>
<script src="modernizr-1.6.min.js"></script>
<script type="text/javascript">
window.addEventListener('load', eventWindowLoaded, false);
function eventWindowLoaded() {
function supportedAudioFormat(audio) {
var returnExtension = "";
if (audio.canPlayType("audio/ogg") =="probably" ||
audio.canPlayType("audio/ogg") == "maybe") {
returnExtension = "ogg";
Search WWH ::

Custom Search