For the in-class test, upload your source code ito a file named "test1.java".
For the takehome test, upload your source code to "test2.java" by next Monday 3/17.
Specifications for the takehome are identical to those for the in-class test,
but the takehome includes all "options" and will be graded to a higher standard.
In your Java code, the variables used for controlling position and speed of the "player" must begin with the first two letters of your first name, in lower case. You may use your first name, or some other name that begins with the same two three letters. (If your first name is "George" then the variables could be georgeX, georgeY, georgeDX, georgeDY or you may use something like geronimoX, geronimoY, etc. or simply geX, geY, etc.
Features marked as "OPTIONAL" are required for takehome, but may be omitted on the in-class test.
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.