CST 112 Midterm exam (2011 Nov. 18)
To receive credit for this exam, make sure you enter name where required, and name the files correctly

SPECIFICATIONS:

THE SCENE:
The 800x600 scene should show a light blue sky, with a light-brown (desert) area underneath, and grass along the bottom. For extra credit, you may make some hills along the horizon.
SCORE & SIGNATURE: ahe score should be displayed prominently in the upper-right portion of the screen.
Be sure to display your name in the lower-left corner.
GRASS (waving): Grass should be series of dark green, vertical lines rising up from the bottom of the screen, each 20 pixels high, spaced 20 pixels apart.
For extra credit, make the grass "wave" in the direction that the mouse is moving. Subtract the X coordinate of the previous mouse position from that of the current mouse position, and add that difference to the X coordinate of the top of each line.
NOTE:: Be sure to draw the scene first, to avoid erasing the hero, etc.

GREEN HERO:
The "hero" (player) should be a "stick-figure" approximately 40 pixels tall, with two arms, two legs, a thicker body, and a circular head filled with green (except when hero is hit by something). The hero always follows the mouse,

RED BALL:
The red ball travels diagonally. Each frame, it moves 5 pixels horizontally, and 2 pixels vertically. (0.4 slope). The ball must "bounce off the walls" and also "bounce away" when hit by the hero.
BALL HITS WALL:   Ball bounces off "walls" surrounding screen, reversing direction in X or Y.
HERO HITS BALL:   When the hero hits the ball, his score increases by 3 points, and his face turns pink for the next five frames. When hit by the hero, the ball should reverse direction in X only. (i.e. if the ball was approaching from the left, it should start moving left and vise versa; after the player hits it, the ball should continue moving upward or downward as before.)
To make this more effective, also make the ball bounce back (in X only), when hit by the hero.

BLUE BOMB:  
When the mouse is clicked, create a "bomb" (a blue ellipse, 30 pixels tall, and 15 pixels wide) that starts directly above the Hero, and falls downward at a rate of 10 pixels per frame. As it falls, the X position of the bomb randomly changes by up to 20 pixels left or right, each frame. (For extra credit, start the bomb at zero velocity and make it accelerate faster as it falls and/or vary its X position randomly by up to 10 pixels.
BOMB HITS HERO: If the bomb hits the hero, he loses 20 points, the background becomes black for that frame, and his face turns gray for the next 10 frames. (The bomb continues falling, unchanged.)

FIVE PURPLE BULLETS:
Every second (30 frames), a set of five "bullets" begins moving from left to right across the entire width, at a rate of 50 pixels per frame. The bullets are 100 pixels apart, vertically; the topmost bullet should start at the same height as the ball plus or minus a random value of up to 20. Each bullet is a purple rectangle, 20 pixels wide and 10 pixels high. (For extra credit, have the bullets randomly move a few pixels up or down each frame!)
BULLET HITS HERO:
If the hero is hit by ANY one of the bullets, he loses 10 points, and the background becomes light-purple for that frame
Since the bullet is travelling fast (50 pixels per frame), a "hit" means that the bullet's X coordinate is within 100 of the Hero, and the x coordinate is within 10.

CODING STANDARDS:

See the coding standards from previous projects; they apply here, too. Also: To receive credit for this exam, make sure you enter name where required, and name the uploaded file correctly as: "midterm-Lastname.pde"

MAIN PROGRAM AND STARTING CODE:

Start with a copy of the code at: The global data and draw() method are shown here, for reference.

//// The name of this file is "midterm-YOURNAME.pde"

//// GLOBAL DATA  ////////
int score=0;					// Score for the game.
float xHero,yHero;				// Position of our "HERO".
float xBall,yBall, dxBall, dyBall;		// Position of the ball.
float xBullets,yBullets, dxBullets, dyBullets;	// Position of the first bullet.
float xBomb,yBomb, dxBomb,dyBomb;		// Position of the bomb.


void draw() {
	//// Move everything; then draw everything.
	//// MOVE:  ball,  Bullets, bomb, hero.
	moveBall();
	moveBullets();
	moveBomb();
	moveHero();	// Also show effects of hits, etc. (and update score).

	//// DRAW:  scene + ball,  Bullets, bomb, hero.  Also show score.
	drawScene();
	drawBall( xBall, yBall );
	drawBullets( xBullets, yBullets );
	drawBomb( xBomb, yBomb );
	drawHero( mouseX, mouseY );	// Hero follows the mouse!
}