Assignment4: CMPT 101/104 SimonFraserUniversity, School of Computing Science
Due by Mar19, 2004
Please refer to the assignment web page for details of assignment preparation.
You are part of a software development team developing look-alikes of classic video games. Below you are given a description/specification for your contribution to a breakout look-alike. Your task is to write the basic classes needed to build and display the image of a level. Your classes will also be part of a user level design tool to be included with the game.
Your deliverables are as follows
- (50 points)A GUI that can be used to request user input for user designed levels and build a Level that can be displayed using a provided Java applet.
- (50 points)A set of classes that can be used to build the Level based on the input from the GUI
The problem can be stated as follows and should be used to identify and develop the required objects.
The level is built of rectangles of a particular size.
- The horizontal length of each rectangle is determined by how many rectangles make up a row across the screen. There are numInRow rectangles in each row. These rectangles completely fill the horizontal length available on the screen xDimScreen.
- The vertical width of the rectangles is determined by the layout of the screen. It can be derived from the y dimension of the screen is yDimScreen, the thickness of the entire level, levelThickness, the number of rows of rectangles in a wall, rowsInWall, the number of walls in a level, wallsInLevel, and the spacing between successive walls, wallSpacing (see diagram)
- The position of each rectangle is the position of the upper left corner of the rectangle in pixels on the screen. If the screen illustrated on the next page is x=400 by y=600 pixels and yOff is 150 pixels, then the locations of the two leftmost rectangles in the top row are (xlocation = 0, ylocation=150) and (xlocation=40, ylocation=150). The position is needed for the graphics routines to plot the rectangle.
- The color with which the rectangle is filled on the game screen
The rectangles form rows which fill the entire width of the screen. Each row can be thought of as an array of rectangleswith numInRow elements, RectangleArray[]
The rows are stacked, with no spaces in y between them to form walls. A wall is made of rowsInWall rows. A wall can be thought of as an array of rows, RowArray[]
The walls are stacked allowing for possible spaces between them of size wallSpacing pixels (y coordinate only). If more than two walls are used the spacings between all walls will be the same. The only possible exception to this is that the first wall can start any distance, yOff, from the top of screen. The offset from the top of the screen is not related to the spacing between remaining walls. A level can be thought of as an array of Walls, WallArray[].
To specify the layer completely each rectangle must be placed in the correct position on the screen. The form of each level will be as illustrated below. So that your code will integrate with other teams building other components of the game (and with the provided applet for plotting) please use the variable identifiers indicated on the diagram and in the text of this assignment.
The following basic specifications should be requested by the GUI
- levelThickness,
- yOff,
- wallSpacing,
- rowsInWall,
- wallsInLevel,
- numInRow
- yDimScreen,
- XDimScreen
All other quantities should be derivable.
Your GUI should include
- a Close button
- a button to build the level and print a list of the resulting rectangles using the print functions associated with your classes..
Your GUI should be implemented in a class called GameLevel
Each of the classes you develop to build the level should include constructor/s, set and get functions for each variable member of the class, and a print function to print the locations, sizes and colors of all rectangles in the object, one rectangle per line. The information about each rectangle will be printed without any labels. The line for each rectangle will include four integers followed by a variable of type Color in the following order
X coordinate Y coordinate length width Color.
These print functions should print to the console. Use your print functions to test the correctness of your classes during development.
When your classes are correct you may modify and use the applet provided to display your generated levels.