CST 112 Project #5  
"Dog Race" using Arrays of Objects

I N S T R U C T I O N S

Rewrite your code from Project #4 & Exam #4 (p4.pde & t4.pde),
using arrays for multiple objects, and add the additional features described below.

Your declarations should look something like this:

	// Declare arrays of objects: //
	int nb=7, nd=4, nv=nd-1; 
	Button[] b=   new Button[nb];
	Dog[] d =     new Dog[nd];
	Varmit[] v =  new Varmit[nv];
	Bird blue;
	String[] names = { "Rex", "Spot", "Mutt", "Lassie", "ALL" };

Note that the above code only constructs the arrays; you must also construct each instance of the objects, with some initialization statemements like these:

	//// Initialize the objects //
	float yDog=yTracks;
	for (int j=0; j<nd; ++j ) {
		d[j] = new Dog( names[j], start, yDog );
		yDog = yDog + 100;
	}
	blue = new Bird();

Additional features for Project #5: (p5.pde):





Required features from Test #4 (t4.pde):

  • Blue bird flies slowly, back & forth, above horizon.
  • Grass along horizon: green blades 20 pixels apart.

  • Small red triangles every 100 pixels, along the bottom, from start to finish,
  • Within each track, draw a red line & text every 100 pixels: to indicate distance: 100, 200, 300, 400, etc.
  • As dogs race, draw a red circle around the leading dog.
    	//  You may use code like this, to draw the red circle:
    	stroke(255,0,0); 	  	
    	color( 0,0,0, 255 );        // Transparent fill.
    	ellipse( x, y, 50, 50 );	
    	stroke(0);	            // Restore defaults.
  • Click the mouse near any dog to move that dog back.
  • Add a button to drop a brown "bomb" from the blue bird.
  • If bomb gets near any dog, send that dog back to the starting line!

    Required features from Project #4 (p4.pde):