Assignment 1
COMP 106



The main project in this course will be to create a computer game loosely based on the classic video arcade game Asteroids. In this game, you fly a spaceship around blasting asteroids into smaller and smaller bits before they collide with you. Each assignment will be to design and implement a progressively larger piece of the game, until each of you will have created your own complete game. We will call our Java game DisAsteroids, since we're not really creating a full replica of the original game and to avoid lawsuits.

For this assignment, you will make a simple skeleton for this game. You should create a Java program using the Swing graphics package to create a window for your game. The window should contain the following elements that your game will eventually need:

Drawing Area

This is the section of your window where the main action of the game will play out. This is the area where your spaceship will fly and asteroids will be blasted. For this assignment, just create a drawing area widget that will consume a significant part of your main window. (This object can be similar to the MyCanvas object used in lecture examples and subclass JComponent.) Inside this drawing area, draw some simple shape to represent your spaceship and maybe sprinkle a few stars in the background.

Control Panel

Our game will surpass the original in that ours will be customizable, using widgets in a control panel. For this assignment, create a control panel, perhaps a subclass of JPanel. Add at least one widget to the control panel. For now, interacting with these widgets (pressing a button, selecting an item for a list, etc) should just cause a message to be printed to the command line. For example, clicking Button1 might result in "Button1 was clicked" to be printed to the command line. For this assignment, you can use any layout for the widgets (FlowLayout is the default). Don't worry yet about how the widgets are positioned within the control panel or their spacing.

Scoreboard

This area will display information about the current game in progress, such as the current score, level, timer, and number of asteroids blasted. For this assignment, just create a separate panel that will consume a relatively small part of your window. Later, you will put some widgets into it to display the score.

Other Considerations

Your program will create the main window, create the widgets and lay them out, create any other data objects you need, and install listeners for your widgets as needed. Then, it lets the Java window system take over, providing the main loop.

To set the size of your canvas in a FlowLayout, you will probably need to use: setPreferredSize (new Dimension (width, height)) rather than: setSize (width, height). You can also look ahead at the Layout.java example for more sophisticated ways to lay out your window.

You can play the original game or get more information here.


Java Software

You should use Java and Swing, we are using version 1.5.0 in class demos, 1.2, 1.3, 1.4.0, 1.4.1, or 1.4.2 should be fine too.

You can download the Java software from the link on the course home page and run on your own machine. Or you can run it on the suns, type (or put into your login profile): use jdk1.5.0_09 to put it on your search path and then run from the unix command line. You can also use the machines in the Windows NT lab, where Java should should already be installed. Your code should be portable among all of these platforms, but if there are any incompatibilities, your code must ultimately compile and run on the TA's machine, which will be a Windows PC. We will use this first assignment to discover any incompatibilities we didn't know about.

Note: If you are having trouble running java on your PC, make sure the CLASSPATH environment variable is not set. Some other program installations may have set it automatically. In Windows, the environment variables are in the System control panel under Advanced / Environment Variables. You may also want to add the directory where the javac program lives (typically something like C:\Program Files\Java\jdk1.5.0_04\bin or C:\j2sdk1.5.0_04\bin) to your PATH environment variable. You can add also this directory to your PATH variable temporarily, just in a single window, by typing set PATH=%PATH%;C:\...etc... on the command line.


Programming Practices

For this assignment focus on writing readable code. In short this means:

You should follow these general Java programming practices:

And, finally, for uniformity please name your Java class that has your main program in it Main, in file Main.java

Coding style will constitute a increasingly large percentage of your grade as the semester progresses.


How to Submit Your Programs

Follow the procedure here to submit your assignment.

T.A.

See the course home page for office hours and contact info.

Grading

Drawing area with a shape/drawing to represent your spaceship 2 points
Control panel with at least one widget. 2 points
Interacting with control panel widget prints out a message to the command line 2 points
Scoreboard panel 1.5 points
Follows all guidelines in Programming Practices section above 1 point
Adds something more, does something new, or significantly surpasses any of the preceding criteria 1.5 points, see below

Creating an excellent, nontrivial software application requires creativity beyond what your customers, or professor, can explicitly mandate. In general, great software satisfies a set of general requirements or requests, and then adds something beyond that. Grading for the assignments will reflect this fact. Satisfying exactly the bare minimum for each assignment will merit a grade of approximately 75% or 85%, depending on the specific assignment (15% for this assignment, as listed above). The remaining points will be awarded for additional work that adds the special something. This is not necessarily easy to do. You will be both the software designer and the software developer in this course. It's not just the implementation that is important, but also the design of the application. If you do this, include a brief description in your readme file, as noted in the submission instructions.