next_inactive up previous


Final Project

CS 135: Computer Science I

Spring 2008

Objective

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
\includegraphics[height=2.0in,width=4.0in]{figs/splash.ps}

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
\includegraphics[height=2.0in,width=4.0in]{figs/defaultMap.ps}
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.

  1. You must have a splash screen
  2. 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.
  3. You must use the UP, DOWN, LEFT, and RIGHT arrow keys for playing the game.
  4. Hitting one of the arrow keys above causes the cursor to begin moving and tracing its motion with a velocity of one unit every $\frac{1}{5}^{th}$ of a second. You can do this with a call to halfdelay(2) during curses initialization. This is you default game speed.
  5. Moving your 'O' over a position with food, allows you to eat the food and removes the food from the screen.
  6. When there is no more food, you leave the game
  7. 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.
  8. When playing the game, you must show the changing score and the number of lives left on the screen.
  9. Lives:
    1. You must start with three lives.
    2. If you hit a wall you lose a life
    3. If you have zero lives you leave the game
  10. Score
    1. You must start with a score of 1000
    2. Every time through the game loop you lose one point of your score
    3. Eating food gives you a 100 point bonus
    4. If your score reaches 0, you leave the game

  11. You must use multiple colors in your game.

  12. The 'Q' and 'q' characters quit the game at any time.

  13. You must have a splash screen to start the game with the game's name and game author names on the screen.

  14. 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.

  15. 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.

  16. 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.

  17. Your cursor must never leave the boundary defined by your terminal (command) window.

  18. 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
    ################################################################################
    ################################################################################
    

    1. Assume that the map file has exactly $24$ rows by $80$ columns, the default terminal window size
    2. '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
    3. '+' represents locations with food
    4. 'o' represents your starting location (there is one 'o' in the file at row 13, column 29)
    5. '#' represents wall locations

  19. You must have at least three maps and corresponding map files.

Extra Credit

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.

Level 0 (5 points)

Level 1 (5 points)

Handing it in

There are two deliverables for this final project.

  1. 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
  2. Due on May 7: A complete implementation of the game and an updated design document in a folder/binder with the following items
    1. Cover sheet with
      1. Project title
      2. Section Number
      3. Your names (both names if you are in a group)
      4. Your email (both email addresses if you are in a group)
      5. Your TA's name
    2. 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.
    3. Executable for the project on the CD/USB stick.
    4. Screen shots for all error-free test cases
      • Identify and annotate each screen shot. In other words, describe what each screen capture is showing.
    5. map.txt and score.txt for all error free test cases.
    6. Testing on at least one case where you catch a file I/O error
    7. Hardcopy of your source code (printout)

Ask an instructor or TA if you have questions. Start now!.

About this document ...

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


next_inactive up previous
Sushil Louis 2008-04-21