Computer Science 1xx – Assignment #N

DUE DATE: mmddyyyy  

Random Numbers, Simulation/Calculation, and Arrays:
The Insect Garden Game

 

Learning Objectives:
(This is a list of the major topics that you, as students, will learn in this assignment:)

  1. Function Decomposition
    In this assignment, you will be given a problem, 'decompose' (break down) a problem into smaller parts, and solve each part with one function/method/subroutine.
     
  2. Algorithm Implementation
    In this assignment, you will be told how a certain goal must be accomplish (you have an algorithm described to you).  You must write a program that implements the described algorithm, in a way that is correct, and as time/space efficient as possible.  Time-efficient means that it runs as fast as it can (while still being correct) ; space-efficient means that it doesn't use excess/unneeded memory (while still being correct)
     
  3. Arrays
    In this assignment, you will need to manipulate an array of numbers, so that your code executes correctly.
     
  4. Instance Variables
    In this assignment, you will need to store certain values across calls to methods (functions), which you will do using instance variables.  While you will need to use these variables in this assignment, they look almost identical to variables you've seen before, and there should be enough explanation in the code that you don't need to spend a lot of time on this topic.

Grading Rubric: This document is available for you use - you should use it to  to help guide your work. The rubric is a document which explains how your work will be evaluated, and is located here.

 

The assignment:

Students will code parts of a simple, limited game in which the player will run around on-screen, and capture insects for points. The game-play will consist of an individual insect (out of a collection of different types of insects) appearing at a random place on-screen, and then semi-randomly wandering around for a limited period of time. If the player doesn't capture the insect (before the time runs out), then the insect disappears. If the player captures the insect before the time runs out, then the player is awarded points (based on the type of the insect), and the player is told how many insects have appeared, how many the player has captured, what the percentage of the total number of insects have been captured, what the average number of points for all the captured insects are, and what the first five recent point-values (for captured insects) have been. Whether the player has captured the current insect or not, a new insect will appear for the player to try and capture.

A compiled version of the game has been provided to you, so that you can play the game (without being allowed to look at the source code solution :)   ) and get a better understanding of how this all works out.

There are extensive comments in the source code for the students' assignment template (the starter project) so that you don't have to examine the entire program (although you're welcome to do so, if you want to!).  The actual code that you have to fill in is clear specified in the source code (it's between the note that says "STUDENTS: YOU NEED TO WRITE YOUR CODE BELOW:", and "STUDENTS: YOU NEED TO WRITE YOUR CODE ABOVE:").  Please note that you don't need to modify anything else in the program, and that you may be penalized if you do modify other parts of the program in order to accomplish the objectives of this assignment.  Further, the sections of the program that you'll need to fill in are summarized below:

Table 1: Methods That You Have To Implement on the InsectCollection class

Everything that you'll need to modify is located in the InsectCollection.cs file.  There are other files in the starter project, but you won't need to change any of the others in any way.  Below is a summary of what you'll need to do to each method, in order to successfully complete this project. 

 

You will need to keep in mind that the InsectCollection class will be responsible for creating new insects, and for keeping track of all the statistics about insects - the total number of insects that have appeared on the screen during the game, how many were caught by the player, what percentage of the total insects were caught by the player, what the average point-value of all the insects caught is, and the first five point-values that the player catches.

 

Data Field Name

Type

Description:

You're free to add any data fields

that you need to, in order to accomplish

the objectives set forth in this assignment

Note: all data fields should be marked private (if you need to expose them, use Properties, or accessor/mutator methods)

Method Name

Description:

<instance variables> You may need to create some instance variables in order to keep track of stuff.  Or you may not - the choice is up to you!
Constructor

The constructor initializes the InsectCollection object, so that it is ready to be used by the rest of the program. 

You may need this in order to initialize data, or you may not - the choice is up to you!

PlaceANewInsect

When this method is called, it must randomly determine the place to put a new, yet-to-be-created insect.  You must make sure that the insect appears INSIDE the screen.
Once you've done that, you will then need to call the CreateInsectAt method in order to tell the program to create the new insect, where you want it.  Examples of this provided in the starter project. 

CatchInsect

This method will figure out if the insect has been caught (i.e., if the player has moved the net over the insect, thus catching the insect).  The logic that figures out if the insect has been caught has already been written, and is provided for you. 

You will need to fill in any code that you want to run in response to an insect being captured.  There are comments in the code indicating where to insert your code.

InsectStatus

You will need to write this method, in it's entirety. This method will need to generate (and return) the string that is displayed at the bottom of the screen.  Your string needs to be visually identical to what you see in the provided sample game (except for spaces - you can have an extra space or two, and not receive a point penalty).

Please note that since one of the learning objectives of the assignment is for you to learn how to use arrays, you will need to keep track of the first five scores using an array.

 

Getting started:

    From here, you should download the students' starter project, and examine the InsectCollection.cs file.  Your job will be to add code to that file, so that the program accomplishes everything that is specified in the assignment.  Everything that you need to know about this assignment should be found in this document, and in the starter project (and in your textbook/lectures/lecture notes).  In particular, this assignment has been designed with the intention that you do not need to know anything about how XNA works, in order to successfully complete this assignment.  While you are welcome to browse through the XNA code for in the project, you shouldn't need to understand any of it.  Having said all that, there are a couple of things to keep in mind, as you start this project:

How To Play The Game:

 

How To Play The Game:
Game/Program Controls:XBox
When running the game/program, you can control it using the following Gamepad controls:
  • Left Thumbstick to move the circle

  • Left trigger to decrease circle radius

  •  Right trigger to increase circle radius

Game/Program Controls: PC
When running the game/program, you can control it using the following keyboard controls:

Here is the keyboard to controller mapping.

 

Group Work, Commenting:

 

            You are not allowed to work in groups for this assignment.  You should start, finish, and do all the work on your own.  If you have questions, please contact the instructor.

 

            Additionally, you should aggressively comment your code, paying particular attention to areas that are difficult to understand.  If you found something to be tricky when you wrote it, make sure to comment it so that the next person (the instructor, who's grading you) understands what your code is doing.  It is not necessary to comment every single line.

 

The purpose of new requirement is to both help you understand, and have you demonstrate, a thorough understanding of exactly how your program works.

 

Every file that you turn in should have:

·        At the top of each file that you normally edit, you should put your name (first and last), the name of this class (“BIT 142”), and the year and quarter, and the assignment number, including the revision number, which starts at 0 (“A2.0”).  If you’re handing this in again for a regrade, make sure to increase the minor version number by one (from “A2.0”, to “A2.1").
You normally edit the C# source code files (.CS files), and any Word documents that you're handing in (if any).
You do not normally edit the .SLN or .CSPROJ files, and so you should not try to put this identifying information in those files.

 

In general, you should make sure to do the following before handing in your project:

·        All variables used should have meaningful names.

·        The code should be formatted consistently, and in an easy to read format.   

 

What to turn in:

 

·        A single electronic folder (a directory).  This folder should contain:

o       The source code for the program – all the .CS files in your project.
I would prefer that you include the project files – stuff ending in .SLN and .VCPROJ, so I can build your project more easily.  If you can save these files (the .SLN / . VCPROJ) into a file format that can be opened by VS.Net 2003, that would be great.

o       You have to name the folder with your last name, then first name, then the assignment number (both the major version – 2, and the minor (revision) number – 0).  Example: "Panitz, Mike, A2.0"

 

·        You should not include the Debug directory, or anything from it.  I will dock you a couple points if you do.  Also, you don't need to include your .NCB file, if it's present.

 

How to electronically submit your homework:

 

There's a link on the homework page to the document that guides you through handing in your work, using the SourceGear Vault program.

 


This document and the related materials are developed with support from Microsoft Research Computer Gaming Initiative under the Computer Gaming Curriculum in Computer Science RFP, Award Number 15871.