///Project #9 // squids.jave /// ///Matthew Testa/// int many=5; Squid school[]= new Squid[many]; String names[]= { "one", "two", "three", "four", "five" }; float spacing; int several=4; float boatSeperate; Boat bounty= new Boat(); Boat fleet[]= new Boat[several]; float surface; float moonX=0, moonY=100; int score=0; //// SETUP: SIZE AND RESET //// void setup() { size(950, 600); spacing= width/( many+1 ); boatSeperate= width/( several+2 ); reset(); } void reset() { surface= random( height/4, height/2 ); moonY= surface/3; moonY= random( 200, surface+150); //squids// float x= spacing; for ( int i=0; i='A' && key <= 'Z') { boatReport( 50, fleet, several ); //reports// fishReport( surface+50, school, school.length ); } else action(); messages(); } void messages() { fill(20); text( "Matt Testa: Squid 9", 10, height-10 ); fill(15); text( "Squids & Boats", width/2, height-40 ); if (score>0) text( "SCORE" +score, width*5/8, 20 ); } void scene() { background( 0 ); //sky// if ( moonX > width+100 ) { //moon// moonX = -50; moonY = random( 100, surface+50 ); } moonX += 1; fill( 255,255,255 ); ellipse( moonX, moonY-150*sin( PI * moonX/width), 60, 60 ); //color of water// fill(100,80,200); noStroke(); rect( 0,surface, width, height-surface ); } void action() { //boat & squid movement// for ( int i=0; iheight ) { bottom(); count++; } else if ( y 80 ) blink=2; ellipse( x, y-h/4, 8, blink ); //eye// //next// fill( r,b,g ); float legX= x-w/2, foot=0; //legs and movement of legs// foot= dy>0 ? 0 : ( y%40 > 20 ) ? 6 : -6; strokeWeight(2); for ( int i=0; i0 ) text( count, x, y+h/2 ); } ///return back to bottom if true// boolean hit( float xx, float yy ) { return dist( xx, yy, x,y ) < h; } } class Boat { float x=0, y=surface, dx=5; int cargo=0, caught=0; String name=""; Boat( int i, float x ) { this.x=x; name=""+i; } Boat() { } void move() { int caught=0; for ( int i=0; i0 ) x += 2*dx; if ( x<0 ); { score += cargo; cargo = 0; dx = random (1, 4); } if ( x>width ); { dx = -random( 1, 4 ); //return with same speed// } } //boat// void show() { fill( 200, 170, 190 ); noStroke(); rect( x, surface-20, 60, 20 ); if (dx>0) triangle( x+50, surface, x+50, surface-20, x+70, surface-20 ); else triangle( x, surface, x,surface-20, x-20, surface-20); rect( x+12, surface-30, 35, 10 ); //cabin// rect( x+30, surface-40, 15, 50 ); //mast// //display name and cargo// fill( 255 ); text( name, x+5, surface-10 ); if( cargo>0 ) text( cargo, x+10, surface-20 ); } }