// Project 3 // Nick Mercogliano //Global Variables String title = " Project 3"; String author = "Nick Mercogliano"; boolean day = true; float left, right, top, bottom; float horizon; int score = 0; /// Setup Instructions void setup() { size(600, 600); frameRate(30); noStroke(); // Declaring Size Variables left=60; right=width-60; top=40; bottom=height-40; horizon = 200; reset(); } /// Reset Commands void reset() { score = 0; } /// Draw Scene void draw() { scene(); show(); messages(); } /// Show Scenes, Background, Water, Mud, Sun, Boat, Fish void scene() { if (day) { background( 36, 160, 240 ); // Light Blue } else { background( 20, 47, 121 ); // Dark blue } fill( 39, 167, 164 ); rect( 0, horizon, width, height); // Horizon fill( 147, 92, 10 ); rect( 0, height-8, width, height); // Mud or sand } /// Show: Shows items in classes void show() { new Sun(); new Boat(); new Fish(); new Button(); } /// Messages: Title,Author,Score void messages() { fill(255); textSize(28); text( title, width-350, top ); textSize(20); text( author, right-125, height-20 ); text( "Score", right - 20, top - 20 ); text( score, right + 5, top + 5 ); } /// Events void keyPressed() { if (key == 'q') exit(); if (key == 'r') reset(); } //// Classes /// Sun Class class Sun { float x = 0, y = 35; float w = 35, h = 35; float dX; float r = 250, g = 225, b = 35; void show() { fill( r, g, b ); ellipse( x,y , w,h ); } void action() { x += dX; // Moving the sun if (x > width*2) x=0; // Makes the sun come back if (x < width) day=true; if (x > width) day=false; } void resetSun() { x = 0; dX = 1; } }/// Sun Class /// Boat Class class Boat { float x, y; float w, h; float dx; float r, g, b; }/// Boat Class /// Fish Class class Fish { float x, y; float w, h; float dx; float r, g, b; }// /Fish Class /// Button Class class Button { float x, y; float w, h; float r, g, b; }/// Button Class