Game Project

 

Description

This project is due in three weeks.  This homework uses all the material from the course.  It can be involved - start early. 

 

You are to create a game with the following characteristics.

 

Grading

Doing the above will earn you a 90.  You must add some additional capability to your game to receive full credit.  For example, add up/down directions, maybe your obstacle (or bad guy) moves, have "health points", add graphics or sound, etc.  Exceptional additions may receive extra credit.

 

Implementation

 

Recommendations

 

Deliverables:

1.    printed source code

2.   a test plan for the game

3.   in class, give me a copy of all files needed for the game

3.      We will “test” these programs in class!

 

Common input data file structure (for those who want to interchange games)

 

20  <start with the number of nodes you will have>

1    <node #> <optional but good for readability of data file>

You are at the edge of a forest.  A river flows to the south and there is a path running east and west.           

2    <node to the north>      // note: need all four directions, can loop back to yourself!

3    <node to the east>

-1   <node to the south -1= no path>

8    <node to the west>

2    <number of items at this location>

a bow and arrow

a shiny penny

… < for other nodes>

2    < number of obstacles>

5    <node where first obstacle is>

A hungry grizzly bear.

a steak

You’ve been eaten

The bear eats the steak and leaves you alone.

8

A troll

a bow and arrow

The troll clubs you over the head.

You shoot the troll with the bow and arrow and it runs away.

17  <node where the treasure is>

A free pass to Great Adventure.      <description of treasure>

 

Algorithm to read in data:

 

FileReader datafile = new FileReader(“gameData”);

Scanner input         = new Scanner(datafile);

 

// Read # of nodes

numNodes = input.nextInt();

// use the next line to throw away the rest of the line, e.g. any comments we put on it

input.nextLine();

 

Gnode map[numNodes];

for(i = 0; i<numNodes; i++)

{

// read nodes into an *array*.  Do the reads similar to reading the number of nodes

// to read string descriptions, use input.nextLine();

read node #

create a  new node in the array

read description, put in node

read lines for N,E,S,W, and put in "links" to nodes     // can do because array

read # of items at this location

for(j=0; j<numItems; j++)

{

read object description

put in list at map node

}

}

read # of obstacles

for(i = 0; i < numObstacles; i++)

{

read node #

read description, put in node

read “remedy” put in node

read description of what to print if no remedy

read description of what to print if you do have the remedy

}

read treasure node#

read treasure description, save or put in node (if use more than one treasure) (must at least mark the node as having the treasure)