Developing User Interfaces
CMSC 498B
Spring 2002
Prof. Ben Bederson
Project #4
Due April 25, 2002


Purpose

The purpose of this program is to get experience with transforms, animation, and with more traditional widgets and layout.

The Problem

You are going to create a simple game called Drawsteroids where the user has an interface to create, manipulate and modify individual asteroids.  You can think of this as a simple drawing program where the objects that you draw move.  A description of how the program should work follows.  The project will be graded out of 40 points, with points distributed within the following sections as shown.

1. (10 points) The program starts off with a simple rocket ship in the center of the screen that can be rotated with the 'left' and 'right' arrow keys (1 pt).  Pressing the 'up' arrow key accelerates the rocket a little in the direction it is pointing (3 pts).  The rocket has friction and slows down over time (2 pts).  Pressing the spacebar should fire bullets out of the tip of the rocket in the direction the rocket is pointing.  Bullets should travel 3/4 of the minimum screen dimension and then disappear (3 pts).  The ship and bullets should wrap around to the opposite side of the screen when traveling past any edge (1 pt).

2. (2 points) There is a toolbar with two buttons.  A "person running" button that means the program should run in game mode (1 pt).  An "arrow" button means all game action should stop and enter edit mode, and the user should be able to use the drawing tools (see #3) to modify the scene (1 pt).  The buttons should contain images representing the modes.  Pressing either button should set that mode appropriately.  In addition, pressing the 'enter' key should toggle between modes, and should result in the appropriate button being depressed.

3. (12 points) There should be a horizontal split pane (1 pt) with the primary game window filling most of the screen on the right side of the pane.  The left side of the pane should contain a drawing palette.  The drawing palette should have a single column of buttons whose description follows.  The buttons should be a reasonable size aligned at the top of the palette.  The bottom of the palette should be blank (1 pt).  Pressing any of these buttons should switch the system to game mode, and should depress the arrow button in the toolbar (1 pt).  The buttons are:

4. (12 points) When in game mode, all non-ship objects should be handled in the same way.  Each one should be given an initial random rotational speed, and direction of motion when first created.  Each object should then rotate around its center (2 pts), and move in the specified direction at a moderate pace (2 pts).  All objects should wrap around to the opposite side of the screen when traveling past any edge (1 pt).  If a bullet hits an object, the bullet and object should disappear (3 pts).  If the bounding box of the ship hits the bounding box of an object, the ship and object should disappear (3 pts), and the game should end (all objects should stop moving, and all toolbar and tool palette buttons should become disabled) (1 pt).

5. (2 points) There should be "File" (1 pt) and "Help" (1 pt) pull-down menus.  The File menu should have a "New game" option and an "Exit" option which should do the obvious things.  In particular, the New game option should re-enable the buttons if they had been disabled from a previous game ending.  The Help menu should have two options - Instructions and About.  Each should have a single screen window describing how to run the game, and who wrote the program, respectively.

6. (2 points) Make sure game is fun to play (2 pts).  (I mean this, you must tune animation parameters, and all interaction so the game is responsive and intuitive.)

7. (0 points) Other fun things you can do (these are not required or graded).  Make a nice explosion when things get hit.  Make sounds.  Keep score.  Make objects split in half and become half the size when hit, until they reach a minimum size when they should actually disappear.  Make it an applet, and put it on the web.

I'll show the best ones in class.

Hints

If this game sounds very hard, then it is easier than it sounds.  Even though there are many different features, they are mostly many different instances of a single thing.  That thing is a graphical object with a bound box that can be rendered at any rotation and any position on the screen.  That thing should also store an angular speed and a linear direction that it moves in. If you define such a general-purpose object, then all of the objects in the game are just special instances of that object.  For example, the ship will have special controls for manipulating its angle and acceleration, but its basic movement and rendering is the same as the rocks.  Same goes for bullets, and all forms of asteroids.  Your game should have a primary data structure which is a list of these moving objects (sometimes called glyphs).  Then, the main game loop should have a timer which several times a second should tell the game to advance one "step".  Each step should tell each object to turn the appropriate amount and move in the appropriate direction, and then request the entire scene to be repainted.  The paint method should just loops through all the objects and ask each one to render itself.

On the other hand, if this games sounds very easy, your are fooling yourself.  You have two weeks to do this project, and will need it.  Start working right now.

Submitting

Submit your program the same way you submitted the other projects, by creating a zip file of all the source code files related to your project, login to a Unix WAM computer, and run the WAM submit program.  This is course CMSC 498B, Section 0101, Project #4.