Final Project
CS 135: Computer Science I
Spring 2008
- Demonstrate that you can integrate all that you have
learned by developing a complete game: Mazer
Design, implement, and test a complete C/C++ application program that
plays a maze based game: mazer. The objective of the game is to
eat all the food in a two-dimensional map in a minimum amount of
time. The less the time, the higher your score. You will use the curses library and at least one two-dimensional array to implement
your program.
First, run the sample executable that implements less than the minimum requirements for this game. The splash screen should have
at least two options as shown in the screenshot in
Figure 1
Figure 1:
The Splash Screen
|
|
Hitting the 'p' or 'P' key will start the game on a default map stored
in the file "map.txt." Figure 2 is a screen shot of the
default map.
Figure 2:
The default map
|
|
Note that the score is being displayed on the top left and that the
number of lives that you have is on the top right. The '#' represent
the walls of the maze and the '+' signs represent food that you have
to navigate to without hitting walls. If you hit a wall, you lose a
life. You cannot move your 'O' cursor through walls. Clearly, maps are read
from map files and stored in a two-dimensional array.
When you finish playing the game, the program should check
whether you made the sorted top ten list. The current sorted top ten
list is stored in a file ("score.txt"). If your score is in the top
ten, then your full name and score should go on this list. At
some point, you will have to ask the player for their full
name. This list should stay sorted at all times in order of score -
highest to lowest.
Here are the requirements for your program.
- You must have a splash screen
- The splash screen must allow choosing between playing the game
on a default map as well as allow the user to choose a new
map. Handle all error checking if a map file is not found or there is a problem in reading in the map file.
- You must use the UP, DOWN, LEFT, and RIGHT arrow keys for
playing the game.
- Hitting one of the arrow keys above causes the cursor to begin
moving and tracing its motion with a velocity of one unit
every
of a second. You can do this with a call to halfdelay(2) during curses initialization. This is you default
game speed.
- Moving your 'O' over a position with food, allows you to eat the
food and removes the food from the screen.
- When there is no more food, you leave the game
- Pressing the space bar causes your cursor to stop moving. Note
that your score keep decreasing even if you are not moving. Time is
of the essence.
- When playing the game, you must show the changing score and the
number of lives left on the screen.
- Lives:
- You must start with three lives.
- If you hit a wall you lose a life
- If you have zero lives you leave the game
- Score
- You must start with a score of 1000
- Every time through the game loop you lose one point of your score
- Eating food gives you a 100 point bonus
- If your score reaches 0, you leave the game
- You must use multiple colors in your game.
- The 'Q' and 'q' characters quit the game at any time.
- You must have a splash screen to start the game with the game's
name and game author names on the screen.
- You must have a file with the full names and scores of the top
ten players. Full names can be first name only, first and last name
only, or first, last, and middle names (or middle initial). You
cannot even assume that a full name has a maximum of three
components. You may assume that a score followed by a full name is
one one line. You will thus need to use getline() to read
and manipulate the name array.
- The file with scores and full names should have the following format
1200 Deborah Q. Public
1008 Mick Jagger
990 Jane Entwhistle Doe
980 David Banner
894 Lois M Lane
783 Bruce Wayne
560 Hulk
450 clark Kent
245 ringo gold starr
101 John
Note that the file is sorted by score. You will have to read one
integer and then use getline() to get the rest of what is on a
line and store it in a string variable. You have to use getline() because you do not know how many words come after the
score. When you swap score array elements while sorting, you will need
to swap the corresponding name array elements.
- If a player breaks into the top ten, she or he should be in the
sorted top ten list. You must write a sort function (bubble sort)
for sorting by score.
- Your cursor must never leave the boundary defined by your
terminal (command) window.
- Map file format. Here's the map file that corresponds to the
default map in Figure 2.
################################################################################
################################################################################
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb+bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
########bbbb################bbbb###################bbbb#############bb##########
########bbbb################bbbb###################bbbb#############bb##########
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
##############bbbbbbbbbbbbbbbb###########bbbbbbb##############bbbbbbbbbbb#######
##############bbbbbbbbbbbbbbbb###########bbbbbbb##############bbbbbbbbbbb#######
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbb+bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
###################bbbbbbbbbbobbbbbbbbbbbb######################################
###################bbbbbbbbbbbbbbbbbbbbbbb######################################
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbb+bbbbbbb################################################bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbb################################################bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
########bbbb################bbbb###################bbbb#############bb##########
########bbbb################bbbb###################bbbb#############bb##########
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb+bbbbbbbbbbbbbbbbbbb
################################################################################
################################################################################
- Assume that the map file has exactly
rows by
columns,
the default terminal window size
- 'b' represents a blank space where your 'O' character can move
without penalty (losing a life). We use a 'b' instead of a space
character because it is easier to see it and count when you are
using an editor like emacs/vi/notepad to create or edit a map file
- '+' represents locations with food
- 'o' represents your starting location (there is one 'o' in the
file at row 13, column 29)
- '#' represents wall locations
- You must have at least three maps and corresponding map files.
To earn levelX extra credit you must complete all the requirements for
level X. Extra credit is cumulative - if you do both level 1 and level
2 you get the sum of the points for each level.
- Three cursor speeds
- Five maps (two extra)
- An animated splash screen
- Ten maps
- Three difficulty modes. Each mode of difficulty should have a
different number of lives to start with and a different scoring decrement
- Default map name, default number of lives, and other game
configuration information must be read in from a game configuration
file.
- Your cursor should be a five character snake like "OOOOO" with a
head and a tail. Every character in this snake should follow the
head. That is, if the head of the snake hits location
then
every other character of the snake should hit location
in
sequence from head to tail. Ask your instructor for examples, if
this is not clear.
There are two deliverables for this final project.
- Due the week of April 28: A design document for this
project. A sample design document is on the class web page. Turn
this typeset document in to your TA in lab in a binder/folder
- Due on May 7: A complete implementation of the game and an
updated design document in a folder/binder with the following items
- Cover sheet with
- Project title
- Section Number
- Your names (both names if you are in a group)
- Your email (both email addresses if you are in a group)
- Your TA's name
- Source code (.cpp) file(s) for the project on a CD/USB stick with your name and section number written on your CD/USB stick.
- Executable for the project on the CD/USB stick.
- Screen shots for all error-free test cases
- Identify and annotate each screen shot. In other words,
describe what each screen capture is showing.
- map.txt and score.txt for all error free test cases.
- Testing on at least one case where you catch a file I/O error
- Hardcopy of your source code (printout)
Ask an instructor or TA if you have questions. Start now!.
Final Project
This document was generated using the
LaTeX2HTML translator Version 2002-2-1 (1.71)
Copyright © 1993, 1994, 1995, 1996,
Nikos Drakos,
Computer Based Learning Unit, University of Leeds.
Copyright © 1997, 1998, 1999,
Ross Moore,
Mathematics Department, Macquarie University, Sydney.
The command line arguments were:
latex2html -split 1 fpS08
The translation was initiated by Sushil Louis on 2008-04-21
Sushil Louis
2008-04-21