CSCE 4813 - Homework 3
Due Date - 02/25/2013 at 11:59 PM

1. Problem Statement:

The goal of this programming assignment is to recreate the classic video game "Pong" which was created over 40 years ago by Atari. The goal of this game is for two players to bounce a ball back and forth towards each other using a small paddle that can only move up and down on their side of the pong table. When a ball makes it past one person's paddle, the other person scores a point. To keep the ball in play the top and bottom of the screen act as walls, causing the ball to bounce back to the playing area. Similarly, when the ball hits the paddle, it bounces off and moves in the opposite direction towards the other player. The game ends when one person has 10 points.

2. Design:

To implement the Pong game, you must complete the following:

The first step is to display the Pong table:

  • Draw the Pong table as a large rectangle in your favorite color.
  • Draw the top and bottom walls as long grey polygons.
  • Draw the mid-court line as a dotted line of grey polygons.
  • Draw the paddles as white vertical polygons.
  • Draw the ball as a white square.

    The second step is to implement the paddle controls:

  • Move the left paddle up when the user enters 'q'.
  • Move the left paddle down when the user enters 'a'.
  • Move the right paddle up when the user enters 'p'.
  • Move the right paddle down when the user enters 'l'.

    The third step is to implement ball motion:

  • Start the ball at the middle of the board moving in random direction.
  • When the ball touches top or bottom wall, change direction from (dx,dy) to (dx, -dy).
  • When the ball touches left or right paddle, change direction from (dx,dy) to (-dx, dy).
  • To make the game more interesting, add a small random vector (rx,ry) to each bounce.

    The final step is to keep score and show the winner:

  • Increase left player's score when ball goes past right paddle.
  • Increase right player's score when ball goes past left paddle.
  • Restart the ball at the middle of the board after each score.
  • The first player to score 10 points is the winner.
  • Draw something on the screen to show the winner of game.

    Optional: Show the score on the Pong table:

  • One option is to draw the draw square polygons that make up the dot-matrix displays of the digits from [0..9].

  • Another option is to draw polygons corresponding to the seven segments in LED displays of the digits from [0..9].

    3. Implementation:

    You can implement this program using either a bottom-up approach or a top-down approach. If you go for a bottom-up approach, start by creating basic methods and classes, and test theses methods using a simple main program that calls each method. When this is working, you can create the main program that uses these methods to solve the problem above.

    If you go for a top-down approach, start by creating your main program that reads user input, and calls empty methods to pretend to solve the problem. Then add in the code for these methods one at a time. This way, you will get an idea of how the whole program will work before you dive into the details of implementing each method and class.

    Regardless of which technique you choose to use, you should develop your code incrementally adding code, compiling, debugging, a little bit at a time. This way, you always have a program that "does something" even if it is not complete.

    4. Testing:

    Test your program to check that it operates correctly for all of the requirements listed above. Also check for the error handling capabilities of the code. Try your program on 2-3 input documents, and save your testing output in text files for submission on the program due date.

    5. Documentation:

    When you have completed your C++ program, write a short report (less than one page long) describing what the objectives were, what you did, and the status of the program. Does it work properly for all test cases? Are there any known problems? Save this report in a separate text file to be submitted electronically.

    6. Project Submission:

    In this class, we will be using electronic project submission to make sure that all students hand their programming projects and labs on time, and to perform automatic analysis of all programs that are submitted. When you have completed the tasks above go to the class web site to "submit" your documentation, C++ program, and testing files.

    The dates on your electronic submission will be used to verify that you met the due date above. All late projects will receive reduced credit (50% off if less than 24 hours late, no credit if more than 24 hours late), so hand in your best effort on the due date.