Assignment 1: PONG
CS 445 /
645 Introduction to Computer Graphics
Fall 2001
Due:
Midnight, Wednesday, Sept 12th
What better way to demonstrate mastery of computer graphics than to recreate the first arcade game, PONG (well, one-player PONG)? Your project will use OpenGL to render the walls, paddle, and ball of the PONG game. This project is intended to be pretty easy – you’re doing some simple vector math and we just want to make sure everyone can get OpenGL to work. You can use Unix, Linux, or Visual Studio to develop your system, but do not use any machine specific libraries (like the win32 API). For example, you should not have to include “windows.h” to compile your program.
For an extensive review of the history of PONG, check out:
Be warned there are tons of popup ads.
The skeleton code gets you started by creating an OpenGL window, a walled court, a paddle with mouse control, and a ball that moves horizontally. You’ll need to make the ball move at a variety of angles and bounce off the walls and the paddle. The details of what you must do are provided below.
Here is a sample solution.
1: (20 points) Your program must accept the following
command line arguments:
ball_x_pos: Do something intelligent if the ball
position is out of range
ball_y_pos: Do something intelligent if the ball
position is out of range
ball_trajectory: specified in radians ranging between –p and p. 0.0 radian should be a horizontal
movement to the left of the screen.
Positive values are upwards.
paddle_y_pos: Do something intelligent if the paddle position is out of range
The arguments will be separated by
spaces (no commas) on one line. For
example: pong 50 50 1.2 120
2: (10 points) Make the ball move in specified directions. The skeleton code includes a variable called “BALL_STEP” which indicates how far the ball can move each step. Make the ball move in specified direction at a constant velocity, “BALL_STEP”
3: (30
points) Your program must correctly identify when the ball has intersected
either a paddle or a wall and compute an appropriate rebound (perfectly elastic
reflection). For example, if the ball
hits with an angle of .3 radians, then
it will bounce off with an angle of -.3
radians. Some penetration of walls is
allowed (because you won’t be checking ball position frequently enough) but the
bounces should look good. Pay special
attention to bounces in the court’s corners and off the paddle’s corners (use
the command line arguments to test specific cases – we will!).
4: (10
points) Make sure the paddle does not translate outside of the playing
court. Identify when the paddle has
reached its limit and prevent it from moving any further. No part of the paddle should ever penetrate
any wall.
5: (10
points) Every time the ball gets past
the player’s paddle and exits off the right edge of the screen, a point will be
counted against the player. Keep track
of the score with an internal variable and quit the game when a score of 15 has
been reached.
6: (10
points) Document the places in the skeleton code where you make changes. Add comments that explain the functions of
your code segments.
7: (10
points) Perform the following procedures to turn in your code:
2.
Hit (9) to escape to unix shell
3.
type: cd /courses/cs/445_ brogan/Students
4.
type: mkdir <username> where <username> is your UVa ID
(dcb8j, is mine)
5.
type: chmod 770 <username>
6.
In your directory, create a subdirectory named “Exercise1” where
you will put all your source files, binary files, and project/make files.
7.
type: exit
You can either access this
directory via ftp, by home directory service, or through UNIX NFS (/courses).
Remember, we will be using the
‘date’ on each file to verify that you turned it in by the due date. Do not ‘touch’ any of your files in this
turnin directory after the turnin date
or you may lose a late day.
Hints,
Code, and Setup
The glut.h file and glut libraries: http://www.opengl.org/developers/documentation/glut.html
OpenGL (normally included with OS):
http://www.opengl.org/users/downloads
Collaboration and Use of Materials on the Web
You can use any materials you find on the web for this assignment.
You can talk with one another about your program, but do not look at anyone’s code and do not show your code to anyone.
Late Days
Though I recommend saving your late days for future assignments, remember that you have five late days to spend throughout the semester. Each late day extends the due date of your assignment by one day.