Assignment #4 Description

In this assignment you will begin to construct the entities that you want to have in your game. You should probably create all the subclasses of GameEntity that you intend to use, though you don't have to complete all of them for this assignment. The ones that don't move should be easy to do and you should be able to complete those. You also need to edit your Player code so that your Player interacts with those Entities in the way that it should. In order for your game to be able to use all of these game entities, you need your Screen class to actually be able to hold a real list of GameEntities. For this reason you will also need to write some form of entity list that you can put into your Screen class so that the addEntity, removeEntity, and createEntityIterator methods can work. The list of mine that you used before is not in the new JAR file for this assignment.

Design

The design for this assignment will include javadocs for the classes that you will write. It should also include text descriptions of your implementation of Player. It will also include all of the classes that you wrote for the last assignment. Your project is going to continue to get larger over the semester and it should include all your previous work so that someone can see how everything fits together.

Remember that the design should put in comments for every class and method that tell two things. It needs to specify how the classes fit into the game play as well as give some implication as to what the methods are going to do to make that a reality.

As always, please follow the instructions in the main project page for where you should put your documentation.

Code

This assignment will have you writing quite a few classes though many of them will be similar. The code can be broken up into three main pieces. You won't necessarily write them in this order. In fact, I would recommend writing one GameEntity, then write the list implementation, then both create the other GameEntities and edit the player to interact with those Entities.

GameEntities: Try to think of all the things in your game that should be entities. You will create classes for them that implement the GameEntity interface and implement the methods in it. You are familiar with the methods already because you had to write them for the Player class as well. If an entity doesn't move and isn't animated it might not even really need any code in the update method. Then again, it might make a better block than an entity depending on how the Player interacts with it.

Player Interaction: You also need to write code that will handle the interactions between the Player and the new GameEntities. This code can go in either the Player class or the GameEntity classes. You can think about which one makes more sense for your code. There really isn't a wrong decision here, though some ways will be easier and more efficient than others. Be sure to think about how often the update methods of your entities are being called when doing this.

Entity List: You need to write your own linked list code that allows you to fully implement the addEntity, removeEntity, and createEntityIterator methods of your Screen class. It can be an unsorted, singly linked list. You should not use any of the data structures from the java.util package (you can use the Iterator interface or any other interface, but not the data structures they have written). The objective here is for you to write your own.

You can also modify your Screen class so that getNumEntityTypes and getEntityOfType use your new entities.

NOTES!!! If you are using the screen editor you should first know that this will invalidate all of your saved screens. There is no getting around that for this assignment. Also, you have to do some different things to make sure that your code will save a screen. First, you need to make sure that your new list and the Node class it uses are Serializable. For that matter, anything that isn't primitive or transient in your Screens, Blocks, and Entities has to be either Serializable or you have to declare it transient. This implies the second thing which is that you must make the Images in your Entities (probably BufferedImages) transient like they were declared in Block. You can't modify that class so there is no way you can make the BufferedImage class Serializable. If you don't declare it as transient you will get a runtime exception thrown when you try to save a screen with an entity that has an image.

JAR File

Here is the JAR file that you should use for this assignment. Remember that you only want one JAR file, and it should be in the classpath of your project.