OO Programming and Data Structures | CS 241

05 Prove : Assignment

Overview

Use your knowledge of object-oriented programming to write a one-player Pong game in Python.

Instructions

Configure your system

Before starting on the program, refer to the preparation material for this week about getting the arcade library set up and configured on your system.

Specification

For this project you will recreate a simple version of the classic Pong arcade game.

The following are the basic specifications:

In addition, use the following values:

Object-oriented Design

To help break the problem down into meaningful, cohesive pieces, we can create a number of classes to represent the elements of the game.

In future projects, you will be responsible to determine the classes needed, but to help you get started on this project, we will work from the same design. In addition, one of the benefits of encapsulation is the ability to define a class interface and then have different people working independently on the different classes.

In some sections of this course, students will work in pairs. But for our section, you will work in a pair with the instructor. I will provide a Pong class to represent the game and the rules. This Pong class will assume the existence of a Ball, Paddle, Point, and Velocity class as follows:

Point
x : float
y : float
__init__()
Velocity
dx : float
dy : float
__init__()
Ball
center : Point
velocity : Velocity
__init__()
draw()
advance()
bounce_horizontal()
bounce_vertical()
restart()
Paddle
center : Point
__init__()
draw()
move_up()
move_down()

The provided Pong class will handle all the user input and call the methods of the above classes at the appropriate times. Your task is to implement these classes and methods.

You may download the code to start with here: pong.py. You are welcome to change any of the provided code (and encouraged to add additional "cool" elements to the game play) but you should not need to change anything to achieve the basic functionality.

For simplicity, for this first graphics assignment, you are welcome to put all of your classes in the same .py file.

Code hints and suggestions

Automatic Grading Script (TestBed)

There is not automated test script for this assignment.

Submission

This is different: Instead of copying your python file to the Linux system and submitting it there. Please upload it to the I-Learn assignment.

Assessment and Grading

For your information, the instructor will use these assessment guidelines to evaluate your assignment. Feel free to refer to this to understand the expectations of this submission.