Assignment 3
COMP 106



In this assignment we will add mouse selection and control to our Disasteroids game. You need not be restricted by what you did in Assignment 2. You can redesign your program for this assignment if you wish, but your program should still provide the features and requirements called for in Assignment 2.

Control Panel

Create a control panel of at least three widgets that allows the user to change the configuration of the game. Possible commands include:

Mouse Selection

Next, set up your game to allow the user to select any visual game object by clicking on it with the mouse. This means that you will first need to figure out which object the mouse touched (since the spaceship, asteroids, etc. are not Java widgets). Your program must therefore figure out which object was clicked on, by testing the mouse position against the boundaries of each of your objects.

Once an object is selected, the user should be able to:

Start Button

Add a "Start" button to the game which will begin the game (with nothing moving until the next assignment). It should enable keyboard input for controlling your spaceship. It should also disable those control panel widgets that don't make sense to use in the middle of a game. But keep as many control panel widgets alive as you can, so that some commands are still possible even while the game is being played.

Scoreboard

Add a scoreboard that contains widgets that are updated with information taken from the Game object. And include the scoreboard in your window layout.

Program Design and Practices

(The rest of this still applies from the last assignment)

Your program design should exploit the features of object-oriented programming (encapsulation of code and data, support for abstract data types, polymorphism/overloading, inheritance). In particular, object-oriented programming provides us a good way to handle the various data needed in callback routines. You should use objects to encapsulate each interactive widget with the routines and data you need to use it.

You should provide an object for each interactive widget or small group of widgets you create. That object should hold anything you need to remember about the widget from one callback to another, all the data pertinent only to the command for that widget or that you need to operate this control, (including, in most cases, a pointer to the graph or other outside object to perform the actual action the user requested), and the widget's own listener callback routines.

If you have several widgets that share some behavior or properties, you should organize your objects into an appropriate inheritance hierarchy.

You will have other data that must be accessed by several widgets, particularly shared information about the state of the program or global information about the state of the user interface. Provide additional classes and objects for holding this kind of information.

Remember to trigger your drawing to repaint itself explicitly whenever one of your commands causes a change in the state of the graph that should be reflected on the screen. And remember that the way to change the screen is first to change the data stored in the Graph or other classes and then to trigger the repaint.

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

Design Documentation

In addition to your program, submit documentation about the design of your system in these forms:

Submit this documentation electronically in text form. Include it as part of the readme file that you submit with your assignment.

Grading

  1. Control panel with at least three working widgets (1 point)
  2. Mouse interaction (3 points)
  3. Start button (1 point)
  4. Scoreboard, which reflects the game state (1 point)
  5. Program design (2 points)
  6. Documentation and programming practices (1 point)
  7. Extra, as with the previous assignments (1 point)