Labs

Lab 5.1: Get Smashed...Bananas

Print
References

Launch the Game

This set of exercises is intended merely to familiarize you with the JavaScript1 game that is the basis for the Module 5 lab exercises. The game is an adventure (of sorts) in which you are provided with free tickets to a virtual concert. Your job is to accumulate the necessary items (like money, transportation, clothes, munchies, etc.) and to get yourself there. You do so by clicking on the items you want to acquire and the activities you want to perform, and keeping track of your "inventory" of goods.

1pp. 126, 127, 139–196, 149

The game operates in two modes. When in "Look" mode, clicking on the images presented doesn't actually commit any actions. Instead, messages appear on the screen informing you about whatever you clicked on. Clicking on the images in "Action" mode moves you through the game, taking you places and allowing you to acquire goods and make purchases.

  1. Start the program2 now. Play the game by clicking anywhere on the image presented. Investigate the game thoroughly by clicking on everything in Look and Action modes. Try to make it all the way to the concert.


  2. Reload this page now in your browser3, so that you can start the game from the beginning. Run through the program now with an eye toward answering the following questions about how it is organized. Write your answers on a separate sheet of paper.
    1. What must you take with you to go shopping from the first screen?
    2. What happens if you try to get cash from the ATM when you already have ATM Cash in your inventory?
    3. What happens when you try to go to the convenience store?
    4. Are there any items that you cannot buy at the clothing store?
    5. What happens if you try to check out with the cashier at the store when you don't have any money?
    6. What happens to the ATM Cash in your inventory when you check out with the cashier at the clothing store?
    7. What happens when you select the leather jacket at the clothing store twice?
    8. What inventory items do you absolutely need in order to get to the concert?
    9. What happens when you get to the concert and you click on the entrance (in Action mode)?


  3. Now we'll examine the JavaScript code that implements our game. You can do so in at least two ways. First, you can select View:Document Source (or something similar) while viewing the game page from your browser. Do so now and look over the HTML file, with its embedded JavaScript scripts.
2pp. 13, Mod. 2, 234, 273, 285
3pp. 9, 14–15, 70–71, 143, 146

  1. Since all of the remaining lab activity for this module will involve editing the JavaScript code in the HTML4 file, and since you can't edit the document source on the server, we want you to have your own version of it. The file that we asked you to download, unzip, and save back in the lab exercises for Module 3. contains the HTML code that you need, as well as the image files that are used by the program. If you have not already done so, download and unzip them now. The HTML file, MyGame.html, can be opened by any word processor5 or HTML editor that you like. You can then edit the file, as per our instructions in subsequent labs, and run your version of the game by opening the file in your browser (using the File:Open File Browser command).

  2. Review the code more carefully now. In particular, add comments (comments are lines within the <SCRIPT> tag that begin with "//") to your version of the code to indicate which lines of JavaScript explain each of your answers in question 2, above. That is, add a comment that says "// this explains answer 2a" at the point in the script that explains what items you need in order to go shopping from the first screen. Do the same for questions 2b-2i.
4pp. 29, 70, 82, 89, 90-91
5pp. 28–32, 48–50

Many thanks to the Garden Party for band photos.

Labs

MODULES:


Home Search Resources Objectives Feedback Order Form Credits

Copyright Notice
© 1998 PWS Publishing Company, All Rights Reserved.