Project #2 - Corners - 7% - NOT FINALIZED
due by midnight, T Jun 13
 
Deduction for lateness is 10% per day for 5 days, then no credit.  Start early!

Version 1.0, last updated 05/14/2006

GRADING CRITERION: (0.4% for time estimate, 7.6% for work)

  1. 70% correct execution
  2. 15% documentation
  3. 15% coding practices (maintainability etc.)

Using Microsoft Visual C#, write the Corners game (download to a .NET 2.0 machine, unzip in a folder, and run the prototype).  NOTE: This executable, being a prototype, has not been properly stress-tested, and I don't promise that it won't break or that it implements all features you are asked to implement.

This game was invented by Penn undergrad Kevin Lerman, who has agreed to allow the class to use his idea.

RULES:

  1. The puzzle consists of an 8 x 8 grid of custom buttons, as follows:
  2. Each button is 20 pixels square.  Space between buttons in 8 pixels.  Form background color is Color.LightGray, as is the background of the label at the bottom, except after the game has been won, when the label's background changes to Color.Yellow.  The default button color is Color.RoyalBlue, and the alternative button color is Color.Red.  Each of these parameters must be changeable in a single place within your program.
  3. The number of rows and columns in the grid should be changeable in one place in your program.
  4. A selected button is outlined by a black panel of Color.Black.  In order to located it behind a button to act as an outliner, I had to create it programmatically after creating the grid buttons; the panel had to be relocated for each button, and sometimes made not visible, and its properties include:
       panel1.SendToBack();
       panel1.Width = myButtonSize + mySpacing*2;
       panel1.Height = panel1.Width;
  5. The player's goal is to turn all squares one color.  Clicking a button causes it be selected as shown above.  Clicking another button (which must not be on the same row or column as the selected button) toggles all buttons in the rectangle defined by the two buttons. 
  6. Each legal pair of button clicks resulting in the toggling of a rectangle increments the move count.
  7. The window must be not resizeable.  The About window should also not resize.
  8. The game should tell you when you've won (see the prototype's win behavior) and should display how many moves were used to win.  After winning and before clicking "New Game", buttons in the grid should not toggle, and the caption background color should be yellow, but should revert to gray once the game begins.
  9. The following is a state machine representing the Corners game:
  10. Here is a chart of which GUI widgets should be enabled in which states.  Missing from this chart is the color change of the Moves/Score label when the game is over:
  11. STARTING A GAME: To set up for a "New Game", first set the entire grid to blue, and then simulate a pair of randomly-selected button clicks for each game level.  For example, if the game is at Level 2, you must do the following 2 times: randomly choose a pair of buttons (not in the same row of same column as each other), and toggle the color of all buttons in the rectangle which they define.  If the game is a Level 4, you will toggle a "rectangle" of buttons 4 times.  Allowed levels range from 2 to 5.
  12. When creating a new game configuration randomly, it is possible that the result will be an all-blue grid; please detect this and repeat the set of random clicks until at least one square is not blue.
  13. Please implement an Undo function that can retract moves all the way back to move 0, if desired.  You will likely want to use a Stack object to store button presses to facilitate undoing of moves later.  Each Undo menu click should decrement the count of moves and back the game up to where it was one move earlier. 
  14. Disable the Undo menu when there are no moves to undo, or when a game has been won.
  15. At a single place in your code, you should be able to specify button size, number of rows, and number of columns for both grid sizes.  Your program should adapt the form size if those values are changed.  This means you must place the buttons on the form in code (and not using the Forms designer), and everything must resize itself appropriately when the main form loads.
  16. You should provide an About screen via the menus which displays (at least) your name and the program name and version.
  17. Please display the program name and game-play Level in the main Window title.
  18. Try to make your game behave exactly like my prototype.  You may wish to provide additional functionality, but be aware that it should work well (and be obvious) or you might lose points.  Extra credit is not guaranteed or promised for extra functionality, but I don't want to stifle you if you feel inspired.  NOTE: If you provide any sounds, the user must be able to turn the sounds off.
  19. Your game should refuse to run more than one copy of itself at the same time.
  20. The background and icon of the main form should match the background of the About form.
  21. The game should behave the same when the machine it runs on has either "Small Fonts", "Large Fonts" or any custom font size between those two sizes.
  22. There are three user options which much persist after the program closes, and be restored when it opens again: game play Level, top position of form, and left position of form.
  23. The height of the form should adjust to include the grid, plus enough space for the message label at the bottom.  The layout of the form should be aesthetic (that is, the form should be just all enough but not too tall).  You need to calculate the width of your form at runtime in the top of the Form_Load() method, and then height will be something like this:
    this.Height = this.Width + this.label1.Height + SystemInformation.MenuHeight;
  24. If you have constants that need to be accessed across classes, they should be implemented as properties with the enum keyword (which provides a user-defined type name for a set of integer constants). NOTE: Enums are the way system colors (such as System.Drawing.Color.Red) are defined.
For up to 1% extra credit to your course grade: make the game provide an option to "Resume last game on startup" under a Game menu item.  This option will save the state of the current game (if it has not been won) and restore the game when the program is restarted later.  Any settings or log files should be created in the application directory.  

GOALS:

  1. To practice programming a game in C#.
  2. To practice using a custom control added to a form by program code.
  3. To practice using a Stack object for Undo functionality.

GETTING HELP:
If you need help, try (in preferred order):


TURN-IN:
The turn-in procedure for programming assignments is as follows:

  1. Create a folder with your emailID as its name.  The folder I would create would be pgpalmer; yours will be different.
  2. Copy your Visual Studio solution and project, and all related files, into this folder.
  3. Test your copied program thoroughly to make sure it works.
  4. When fully tested, zip up the entire folder, including all files underneath the folder.  NOTE: Please do not use the "save full path info" option.
  5. Test unarchiving the zip file to make sure it produces all your files and directories, but in whatever folder the person unzipping chooses (such as, on the Desktop).
  6. If correct, log into Blackboard and turn in the zip file (via file upload in your web browser).
  7. In Blackboard, paste the URL of your program spec into the comments area when you turn in your program.

Visitors: Hit Counter