//Tristan Szakacs //Project Two //Could not get the score to work. Also did not know how to //use Random for the fish Y coordinate without them refreshing all over the screen. float boatX, boatY, dx; float carlX, carlY; float steveX, steveY; float lineX, lineY; float boyoX, boyoY; float rodX, rodY; boolean go; boolean fish; float score; void setup() { size(800, 800); } void draw() { background( 50,100, 200); sea(); buttonCatch(); buttonGo(); buttonPress(); score(); } //Creates Button Pressed Function. void buttonPress() { if(mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 50 && mousePressed){ go = true; } if(mouseX > 125 && mouseX < 225 && mouseY > 0 && mouseY < 50 && mousePressed){ fish = true; } else { fish = false; } if(go){ carl(); steve(); boat(); } if(fish){ twine(); } } //Toggles buttons. void mousePressed() { if ( mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 50){ go = !go; } if ( mouseX > 125 && mouseX < 225 && mouseY > 0 && mouseY < 50){ fish = !fish; } } //Creates Go Button. void buttonGo() { fill(100); rect( 0, 0, 100, 50); fill(0,0,0); text("Go", 40, 25); } //Creates Catch Button. void buttonCatch() { fill(100); rect( 125, 0, 100, 50); fill(0,0,0); text("Catch", 150, 25); } //Displays score. void score() { fill(100); rect( 600, 0, 100, 50); fill(0,0,0); text("Score: ", 615, 25); print( score, 640, 25); } //Creates Fish. void carl() { fill( 150, 30, 50); ellipse( carlX, carlY, 100, 50); carlY = 400; carlX = carlX + 1; triangle( carlX-75, carlY+15, carlX-50, carlY, carlX-75, carlY-15); if( carlX > width){ carlX = 0; } if( lineY > carlY && lineY < carlY+100 && lineX > carlX && lineX < carlX + 100){ carlX = 0; } } void steve() { fill( 100, 30, 150); ellipse( steveX, steveY, 100, 50); steveY = 500; steveX = steveX + 2.5; triangle( steveX-75, steveY+15, steveX-50, steveY, steveX-75, steveY-15); if( lineY == steveY && lineX == steveX){ steveX = 0; steveY = 0; } } //Creates Boat. void boat() { score = 0; fill( 100, 50, 50); rect( boatX, 150, 200, 50); fill( 10, 100, 100); ellipse(boyoX + 30, boyoY, 50, 50); boyoX = boatX; boyoY = 100; line(boyoX + 30, boyoY+20, boyoX + 30, boyoY + 50); stroke(3); line(rodX+30, rodY + 30, rodX + 80, rodY - 40); rodX = boyoX; rodY = boyoY; boatX = boatX + dx; if( boatX - 50 < 0){ dx = 2;} if( boatX + 100 > width + 100){ dx = -2;} } void twine() { lineX = boatX + 1; lineY = lineY + 4; line(rodX+80, rodY-40, lineX, lineY); if( lineY > 800){ lineY = rodY - 40; } if( lineY == carlY && lineX == carlX || lineY == steveY && lineX == steveX) { score = score + 1; } } //Creates Sea. void sea() { fill( 0, 90, 30); rect( 0, 200, 800, 600); }