Lab 2: Invaders!

Click in window to set focus, then use RIGHT and LEFT arrows to move launcher, UP arrow to fire.

I. Overview

In this lab, we'll produce a simple version of the classic "Space Invaders" arcade game, consisting of three elements: (1) a shooter that can be maneuvered left and right at the bottom of the screen using the left and right arrow keys; (2) a (single) bullet which can be released from the shooter, and which destroys invaders on contact; and (3) a series of invaders that move inexorably, but unpredictably, down the screen.

Previous labs and demos, especially our "Apple Seizure" exercise, have provided all the technical knowledge you need to create these three elements. We'll step through the building process in class, formulating approaches and code collaboratively. At the end of this session, you will have a working, minimal solution.

II. Process

Step 1: Examine the starter file. You'll find pre-built Movie Clip objects corresponding to shooter, bullet, and invader. Each is linked a corresponding ActionScript 3 class: shooterClass, bulletClass, and invaderClass. Begin by setting up layers and instances for your invaders; then add a layer containing a single instance of bullet.

Step 2: Write the class code for shooter. Note: it's highly similar to bucketClass from "Apple Seizure." Eventually, you'll need to make a modification for the bullet-firing function.

Step 3: Write the class code for invader. Your alien critters should move in the following manner: (a) initially appear off-screen top; (b) hesitate for some random interval before moving; (c) advance a random amount down-screen, then return to hesitation mode; and (d) reset themselves offscreen top after leaving the screen at bottom.

Step 4: Write the class code for bullet. The bullet should (a) appear at the tip of the shooter, and (b) fly in a straight line up the screen once fired.

Step 5: Figure out a mechanism for firing. Obviously, this will involve additions both to shooterClass and bulletClass. You may need to control both the visibility and the movement (animation) of the bullet.

Step 6: Establish a hit test that causes the invader to disappear (reset) when it contacts the bullet.

III. Evaluation

Depending on degree of completion, the basic build described above is worth up to 85 points, corresponding to a letter grade of B. For better results, consider some or all of the following.

86 - 89

ADD ALL THE FOLLOWING: (a) Replace the crude graphics in the starter file with something better; (b) add a working score display (and scoring mechanism); (c) add a Game Over screen with an option to restart. (This last feature will probably require you to use a gotoAndPlay() command, and possibly also a button Symbol, both of which are explained in Perkins.)

90-94

Add any of the following:

(a) Animation for the invaders so they fragment or otherwise change to dramatize a hit; animation for the shooter to indicate firing.

(b) Ground targets (cities, forts, etc.) along the bottom of the screen; make them sensitive to hit-testing against the invaders, and adjust score accordingly, if you include a scoreboard.

(c) Sound effects. This feature requires reading ahead in Perkins.

95+

Add any of the following:

(a) The ability to fire an unlimited number of bullets, with more than one bullet active at once. This feature requires using a Document Class to create bullet instances on the fly. It will also complicate hit testing, requiring some strategy for picking out individual Movie Clips or Display Objects. This may mean assigning some common property, such as name, to all instances of the Bullet. You may also want to look up the topic "Traversing the Display List" in the help files included with Flash CS3.

(b) Sub-class variant invaders with different behaviors, such as damage resistance, size change, and lateral maneuvers. Consider the possibility of invaders that can spawn new instances. This last option will also require a Document Class and dynamic instances.

(c) Create multiple levels, or make your game grow more difficult with time, or increasing score. Again, you'll probably need a Document Class here.

Combinations

Combining items from the first two levels may result in a score approaching 95, but scores above this level require taking on one of the three challenges described for that level, or something equivalent.

IV. Specifications

When you have done your coding, use Publish to generate an swf, html, and js file. Rename the html file index.html (using the four-letter file extension, please).

Below the Flash-generated tags, add a paragraph container (or some sort of list structure), and write a few lines indicating what special features, if any, you have included in your build. BE SURE TO INCLUDE THIS STEP.

Upload all your files, including .fla and associated .as files, to the Lab2 sub-folder in your MULTIMEDIA directory on student-iat.



University of Baltimore Logo

Last updated: 06/24/08 16:26:21
Copyright © 2008 School of Information Arts and Technologies