Homework Assignment 6

RobotWorld


810:062

Computer Science II

Object-Oriented Programming


Due: Thursday, November 17, at 5 PM


Introduction

Let's continue with you designing and building classes of your own. As always, feel free to ask questions early and often!

RobotWars was a fairly simple computer game that I remember playing in the early 80s.  While I haven't been able to find a copy of it to show you, I have found a "pirate-ey" version called "Seven Seas" that you can play online at PopCap games (http://www.popcap.com/launchpage.php?theGame=sevenseas).  You can also play a version that Dr. Schafer coded up .

The game is played on a grid and has fairly simple rules.  You move a friendly robot around the grid.  There are a variety of obstacles on the grid that can either help you (portals) or hurt you (junk piles and evil robots).  Furthermore, the evil robots pursue your friendly robot.  They too are effected by the portals, junk piles, and other robots. Your goal is to move around the board, avoiding things that hurt you while causing the evil robots to crash into junk piles and each other.  If you can cause all of the evil robots to crash, then you win the game.


Task - Implement a version of RobotWars.

You will be constructing your own version of this game for this assignment.  I will STRONGLY encourage you to write your code for this homework using incremental development.  That is, think about the game as a series of small steps, and make sure that you have completed each step before you move on to the next step.  In fact, you may want to save a backup file after each step so that you have something to turn in if you can't make adequate progress on the next step.  I will grade this lab, as a combination of how many steps you get completed, and how well you have used the object oriented design principles.

1)  Set up the basic game board and user interaction

Implement a version of RobotWars that uses the following guidelines

You may use any method to gather user input that you like -- mouse events, button events, keyboard events, etc.  Just make sure it is clear to the user how the robot is moved.

2)  Add in the helpful portals

There will be four portals in our version of this game, located in the four corners of the playing grid.  If your robot moves onto a portal, it is randomly transported to one of the empty squares on the grid.

3)  Add in the dangerous scrap piles and evil robots

Whenever a game is started, you should generate three "scrap piles" and three separate "evil robots" at random locations on the screen. 

4)  Configure the evil robots so they pursue your friendly robots.

After you move your robot (and after he is transported if applicable), the evil robots pursue you.  They do this by moving exactly one square towards you in one of the 8 possible directions.  The screenshot below illustrates the possibilities




 

5)  Complete the functionality

At this point you should be able to move around the screen and have the robots pursue you, but we haven't implemented any concept of winning or losing yet.  After everyone has moved there are three possibilities - you won, you lost, or the game is still in progress. 

The detection of what happened should take place in the following order (some of which you may have already provided).

How complex does my game/code need to be?

You do not need to use fancy graphics to represent the different robots, portals, and scrap piles.  Simple colored circles and/or squares should be sufficient to make the point.

You may design and implement your game in any object-oriented fashion. Keep in mind that, once we have a program built to play the game, we might want to give the player the chance to customize the game in a number of ways. For example:

You are not required to implement a program that supports these "extra" features, but you should should design your program with future extensions in mind.

Of course, you may go beyond the bare minimum of the assignment and choose to implement some of these features. If you do, I'll give you extra credit for your extra effort!

If you do look at either Seven Seas or Dr. Schafer's version, please do not feel that you should limit your interface to the interface they used. In fact, do not submit a solution that looks exactly like either.  Have some fun, use your creativity, and create an interface that takes advantage of Java's capabilities, and your interests.

 


Deliverables

By the due date and time, submit the files: