CST 112 Test #1
+ takehome test


S P E C I F I C A T I O N S

FIELD: Draw a rectangular field for playing a game similar to tennis, with a "net" down the center of the field (as illustrated below). Use the following variable names to describe the boundaries and net position:
        top left center right bottom
Display a title centered near top of the screen, your name at lower left, and a "score" at lower right.

PLAYER: The "player" (using variables thet begin with the first two letters of your first name) should have a rectangular body with its name in text, and a circular head, plus two legs below the body, and two eyes within the head. Do not write two sets of similar statements to draw each leg or each eye; instead, write functions such as eye(x,y) and leg(x,y) that each take two arguments to give the position, and draw a single eye or leg.
OPTIONAL: also show a "tennis racket" (see illustration) pointing to the left or right, depending on position of the ball.

The player may must remain within the right half of the screen, always moving toward the mouse (when possible) at a rate that would cover half the distance in two seconds (60 frames).
However, the player may not cross the net (georgeX < center), nor go out of bounds (top, right, bottom).

BALL: The ball should begin at a random height at left side of the field (left), with a random velocity (DX, DY) and a random color (RGB).
The ball moves at a constant velocity (DX,DY) until it hits a boundary and bounces off. (For left and right, DX is reveres; for top and bottom, DY is reversed.)
If ball hits right side (i.e. the player has missed it!), the player loses 50 points from the score.
OPTIONAL: When the ball hits the left side, it is "served" back but with a small random variation in the velocity
        ballDX= -ballDX * random(0.5, 2.0);
and a "volley "counter" is increased by one; after ten vollies, the ball is replaced by a new ball (starting from the left, with random color and velocity).

ACTION: The ball should bounce away (reversing both DX and DY) when the ball is within 20 pixels of the player:
        dist( ballX,ballY, georgeX,georgeY ) is less than 20

SCORING: Score is increased by 50 points if the player hits the ball while it ball was coming in from the left:
        ballX was less than georgeX
Note that there is no score change when the player mistkenly hits the ball back the wrong way (to the right), because it will bounce off the right wall and lose score points then.

KEYS: If the 'r' key is pressed, a new ball is also created, and the player loses 20 score points.
If the 'q' key is pressed, the program exits.