/// Narada Brooks CST 112 MIDTERM //// String title= "What a Catch Moby"; String author= "Narada Brooks"; int width=640, heigh=480; float surface= heigh/4; //++++ GLOBAL DECLARATIONS ++++// float boatX, boatY; float boatDX=3; float x=100,y=100; float horizon; // SETUP // void setup() { size( 600, 400 ); boatX= 170; } /// NEXT FRAME /// // BACKGROUND // void draw() { //scene(); //Sky and Water// //action(); // Move Boat and Fish. //show(); // Display Boat, Fish, Crawler. //messages(); // Title, Author, Scores. background ( 200, 220, 250 ); fill( 50, 150, 50 ); rect(0,height/4,width,height*3/4); textSize(18); fill(0,158,0); text(" What a Catch Moby", 200, width/40 ); text("Narada Brooks", 10, height/20 ); boat(); fish(); crawler(); move(); action(); } // move boat /// void move() ////move boat { if ( boatX>width) { boatDX= -boatDX; } if ( boatX<0) { boatX= 50; boatY= random( 20, height/4 ); } boatX= boatX + boatDX; // DEBUG: fill(0); text( boatX, boatX, boatY+50 ); text( boatDX, boatX, boatY+60 ); } /// Draw Boat /// void boat() { //orange boat// fill( 211, 85, 6 ); // orange boat color rect( boatX+70, 10, 10, 30 ); // boat stern rect( boatX, 40, 100, 60); // boat body triangle( boatX, 40, boatX, 100, boatX-30, 40 ); // boat front ///triangle(24,150,100,200,110,150); } // Draw Fish /// void fish() { fill( 6, 124, 211 ); //fish color noStroke(); // blends the fish ellipse( 220, 200, 200, 40 ); // fish body triangle( 200, 180, 260, 180 , 260, 140 ); // fish fin 1 triangle( 200, 220, 260, 220 , 260, 260 ); // fish fin 2 triangle( 280, 200, 320, 230, 320, 160 ); // fish tail fill(211,202,6); //fish eye color ellipse( 140,200,10,10 ); // fish eye stroke(0); /// returns regular stroke } // Draw Crawler // void crawler() { fill( 0, 6, 2 ); // crawler body color ellipse( 280, 300, 200, 40 ); /// crawler body fill(211,202,6 ); // crawler fin color rect( 220,260,20,80); // crawler fin } void action() // move boat { if (x>width) { x=100; y=100; } x= x + (boatX-x) / 30; y= y + (boatY-y) / 30; }