Changing the Values of Variables in Scuba Diver

Author: Matt Slaybaugh
Date: October 25, 2006
Level: Beginner

Summary

Scuba Diver is a game in which the player uses the arrow keys to move the swimmer to the goal, off the right side of the screen, before running out of air. Avoid colliding with the fish, which makes you lose air faster!

In this tutorial, you will change the values of some of the variables in the application to make the game easier

Experience Needed
  • Basic Flash experience
Software
  • Flash 8
Files — Scuba.zip (878KB)
  • myglife_scuba.fla
License — "Scuba Diver" (c) 2007, World Wide Workshop Foundation

This software is licensed to the public under the CC-GNU GPL.


The number of the fish in the Scuba Diver game
is determined by a variable in the application.
Description
Change some of the variables used in the game.

A variable is a container for information that may change while running an application. In Scuba Diver, one of the variables is the amount of oxygen in the swimmer's tank.

One type of variable is called a constant. The values of constants do not change while running an application.

In Scuba Diver, two of these constants are totalFish and maxtimer.

  1. Open myglife_scuba.fla in Flash.
  2. Locate the top layer, named Actions and click on the third frame.
  3. Expand the Actions panel by clicking on its title bar. If you do not see the Actions panel, open the main Window menu and click Actions.

    The constants in Scuba Diver are set in the script
    on the third frame of the timeline in the layer named 'Actions'.
  4. In the Actions panel, scroll down until you see line 16, where totalFish is set to the value of 38. This is the number of fish the swimmer will encounter in the game.
  5. Make the game a little easier by changing the value of totalFish to 25.
  6. In the Actions panel, scroll further down until you see line 20, where maxtimer is set to the value of 1500. This is the duration of the game, measured in frames. The game runs at 12 frames per second, so 1,500 frames is about two minutes.
  7. Make the game a little shorter by changing the value of maxtimer to 1000 (don't include a comma) which will make the game last a little under a minute and a half.
  8. Save your changes and publish the application.
  9. Run the game in a browser and you will see fewer fish and find that the game ends more quickly.