CSCI 1321 (Principles of Algorithm Design II), Fall 2007:
Homework 2

Credit

Design 20 points; code 40 points.

Overview

In this assignment you will begin to construct your game following the description that you handed in for the last assignment. You will do this by creating several new classes and interfaces. classes you create will depend on the design of your particular game. What you will be constructing now is the beginning of the ``playing field'' -- the background on which the game is played. To do this, you will write what may seem like a lot of classes, but some of them can be very short, and for others you will have access to source code for the equivalent classes in Dr. Lewis's starter game.

Before reading further, review the Project Description, particularly the section ``The game framework''.

Design

The design for this assignment will include descriptions of all the classes and interfaces you will write (for this assignment) and their methods. As in the previous assignment, you will write these descriptions in the form of comments for the classes you need; they will then appear in the HTML documentation generated by Eclipse (or with the javadoc command). As before, what you turn in does not set in stone the code you write for this assignment or later assignments, but you should try to at least plan fairly carefully what you will do for this assignment.

Step-by-step instructions

Code

For this assignment, you have to write a number of classes, described in the next section (``Classes for this assignment''). This section describes the overall procedure.

Step-by-step instructions

Classes for this assignment

(Read, or at least skim, all of this section before starting your design.)

As you may have noticed from browsing the API for the game framework, many classes and interfaces are generics defined in terms of two basic types, one that extends Block and one that extends GameEntity. These two interfaces are themselves generics defined in terms of Block and GameEntity, and if this sounds to you like infinite recursion -- yes, but this can be avoided by you writing your own class or interface for each of these basic types. I'll call these YourBlock and YourEntity here, but you should give them names related to your game (e.g., PacManBlock and PacManEntity). You will then use these types everywhere the framework wants types that extend Block or GameEntity. YourBlock, and all of your game entity classes will be For example: In Homework 1 you had a MainFrame<BasicBlock,BasicEntity>. In this assignment you will replace that with a MainFrame<YourBlock,YourEntity>.

To make this happen:

Once you have definitions for YourBlock and YourEntity, for this assignment you will write the following additional classes. (This is not as overwhelming as it might sound; for most of these classes you have starter code that you just need to modify.)

For initial testing, you should write your game setup class so that it directly creates a screen and fills it with blocks. Once you're reasonably confident that your screen and block classes are working, you may want to use Dr. Lewis's screen editor (see ``Links and files'' below) to actually build screens for your game. This is a nice visual tool that allows you to build screens using your block classes and save them in a binary format that can be read into your game in the constructor of your game setup class. There is commented-out code in the starter version of this class that you can use as a model for doing this. Warning: Do not put too much effort at this point into creating elaborate screens using the screen editor; almost any change you later make to your screen or block classes will make it necessary to start over (because the saved binary-format representation will no longer be valid -- later in the semester we'll talk about why). However, do try out the screen editor, to make sure the parts of your screen and block classes that interact with it are working right.

Files and links



Berna Massingill
2008-01-17