Assignment #2 Description

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 at least 2 new classes that implement two of the interfaces I have provided and modifying one class that I provided you so that it uses those new classes. Exactly what type of classes you create will depend upon the design of your particular game. What you will be constructing now is the beginning of the "static" background that the player plays on. To do this you will write a class that implements the Screen interface and at least one class that implements the Block interface to populate your screens with. Once you have done this, you will edit the appropriate methods in the GameSetup class so that they use these new classes.

Design

The design for this assignment will should include text descriptions of the classes you add for this assignment, their methods, and what they do in the game.

Again, follow the directions on the general project description for submitting the design.

Code

This assignment will have you writing and editing a fair bit of code. There are three basic parts to this. First you will write an implementation of the Screen interface. You can call it whatever you want. Something that reflects you or your game followed by Screen would be appropriate. For example, if you were writing a version of Pac-Man you might call it PacManScreen. There are a number of different methods that you have to implement for Screen. Each is described in the Javadocs for the project. The class will require a two dimensional array of Blocks and some form of list of GameEntities. For the list, you should use the GameEntityList class that is in the JAR file to simplify your life. Look in the Javadocs for information on this class and the methods you can call on it. Just put a member of the GameEntityList class in your Screen class. You will write a full list of your own in a later assignment. Unfortunately, doing so will "break" the screens that you create now with the editor so don't spend too much time making elaborate maps at this point (you can come to talk to me about this if that is something you feel strongly about). There are two methods that are used by the ScreenEditor that you won't be able to fully implement at this point. You should make getNumEntityTypes return zero and getEntityOfType return null. You will change both of those for assignment #4.

In order for your Screen class to be useful you also have to create some Block classes to populate it with. Here again I recommend giving them names that reflect both the game and their prupose (i.e. PacManWall). The Block interface has documentation describing the purpose of each of the methods in it. Some of them you will leave blank or simply have them return null at this point because you can't complete them yet. The documentation gives you hints as to when this is the case. I'm providing you with one sample Block that you can model yours after. The Block classes are probably the simplest classes you will write because they don't really do much. The only part of them that is in any way difficult is producing an image for them to draw. We will be talking about that in significant detail later in the semester. For now you can build off of the example that I have given you. (See the links below for the sample code.)

After you have a Screen class and a few Block classes, you will need to edit the GameSetup class so that it uses what you have written. There are comments in the code pointing you to what types of changes you should make. If you want to test your screen with the ScreenEditor, you can put code in the constructVariables() method that calls the readScreenVector(...) method of ScreenEditor. It is a static method. However, for debugging you will want code that directly instantiates a screen and fills it with appropreate blocks for your testing. You might want to keep that code around for testing in assignment #3 as well.

Once your screen and block classes are done and tested, you can use the ScreenEditor that I have written for you to easily build a few screens. I don't recommend that you spend much time on that at this point in the semester because odds are high that you will make changes in the next few weeks that will invalidate any of the files you save now. However, you should play with it a bit just to make sure that you are properly following the interface and that your screen class works with it. For help on how the editor works click the link below.

Help with the screen editor program.

To run the ScreenEditor use the command line and run "java -cp PAD2Assn#.jar:. ScreenEditor MyScreen.class SavedFile.bin", where # is replaced by a number and MyScreen is the name of your screen class. In windows the : is replaced by a ;. The SavedFile.bin is the name of the file you want it to be saved in. Also, if the JAR file is not in the same directory you are running this in you will need to specify the path. You can also run the screen editor from inside of Eclipse by selecting the main in the ScreenEditor class. You will need to specify the proper command line arguments in the dialog box if you do that.

JAR file for assignment #2.

Source for GameSetup and BasicBlock. GameSetup you should edit. BasicBlock is provided just for your reference. You can take code from it. This is especially for the graphics code in it because we haven't talked about how to write that yet. You can either put the BasicBlock class in your project and rename it, or you can copy the code from it into your own class.