Assignment #5 Description

This assignment is focused on the active parts of your game. You have already done a bit with this in your player, but now it is time for you to get some entities moving around. As part of this, I want you to write an implementation of PriorityQueue and make your GameSetup create and use one of them. To complement this you will make some moving entities and write them so that they will be updated occasionally. You don't have to finish all of your moving entities, but the more you do now, the fewer you will have to do before the end of the semester.


The design for this assignment will include text descriptions of your implementation of the PriorityQueue and the entities you create. It will also include all of the classes that you wrote for the earlier assignments.

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.

Again it will be submitted by you placing it on the web as described in the main project description.


There are two distinct parts to the coding for this assignment. The first is the PriorityQueue implementation. You can see that interface in the project description. For the implementation, I would like for you to write a sorted linked list. This is not the most efficient implementation of that interface, but it is fairly good and works well for us now. Later in the semester we will be writing a heap based priority queue that can implement the interface more efficiently.

The role of the PriorityQueue in the framework is fairly simple. Each tick, the framework uses the priority queue that it gets from GameSetup to get all of the entities that need to be updated in that tick. It does this in a loop where it pulls off entities one at a time and calls their update methods. After it calls update on a given entity, it adds that entity back into the priority queue. For this not to produce an infinite loop, the entity's update time has to either be larger than the time of the current tick, or -1. When it is -1, the entity will not be added back into the queue at that time. This means that the entity will not have its update method called in future ticks until some piece of code adds that entity back into the queue. Any time an entity is removed from the game (killed or whatever), it needs to return -1 for its update time to make sure that time is not wasted updating it. Your priority queue should not add entities with a negative update time.

Have your PriorityQueue implementation include a main that does some testing of whether or not it works. To do this, you should probably create a "DummyEntity" class or something similar so that you can easily put elements into your queue with various update times. Then make sure that they get pulled off in the proper order.

The second part of the implementation on this assignment is writing the moving or animated entities. This is simply the task of creating some entities that have update methods that make them do something and making sure they get put on the PriorityQueue. This includes giving them the ability to interact with one another as well as with the player. To do interactions between entities they need to walk the list of entities for their screens.

JAR File

Here is the JAR file for this assignment. Make sure that your code complies with it in your classpath (not an older JAR file) because that is how I will be compiling it.