//INSTANTIATE FRUIT// Fruits Melon, Grape, Apple, Orange; //INTERGERS -- VARIABLES// int n=10; //SIZE OF THE SCREEN// void setup() { size(400, 600); smooth(); background(255, 255, 0); //FRUITS// //INITIALIZE// Melon = new Fruits(100, 160); Grape = new Fruits(120, 140); Apple = new Fruits(140, 120); Orange = new Fruits(160, 100); Melon.FruitColor= color(0, 255, 0); Grape.FruitColor= color(126, 0, 40); Apple.FruitColor= color(255, 0, 0); Orange.FruitColor= color(245, 154, 7); } //METHODS THAT ARE BEING DRAWN// void draw() { board(); moveFruits(); screentext(); //CALLING FRUITS// Melon.display(); Grape.display(); Apple.display(); Orange.display(); } //DRAWING BLUE BOARD WIH HEAVY OUTLINE--LINES--NUMBERS// void board() { fill(0, 0, 255); stroke(0); strokeWeight(8); rect(50, 50, 300, 500); //LINES IN THE BOARD// strokeWeight(2); stroke(255); for (int y= 100; y < 530; y= y+45) { line(56, y, 345, y); } //LEFT SIDE OF LINE -- NUMBERS// fill(255); for (int u = 99; u < 530; u = u+45) { textSize(10); text(n, 60, u); } } //ALL THE TEXT YOU SEE ON THE SCREEN// void screentext() { fill(0); smooth(); textSize(40); text("Bounching Fruits", 30, 30); textSize(20); text("Rune Hernandez", 0, 590); text("Take Home Project 6", 200, 590); } class Fruits{ //VARIABLES// float y= 0; float x= 0; float dx = random(4), dy= random(4); float random = random(60); color FruitColor= color(255); //CONTRUCTOR// Fruits(float x, float y) { this.x = x; this.y = y; } //FUNCTION// void display(){ noStroke(); smooth(); fill(FruitColor); ellipse(x, y, random, random); } //MOVE METHOD// void move() { //VARIABLES FOR MOVE METHOD// x = x+dx; y = y+dy; //PARAMETERS FOR BOUNCE// if ( x < 80 || x > 325 ) dx *= -1; if ( y < 80 || y > 515 ) dy *= -1; } } void moveFruits() { Grape.move(); Orange.move(); Apple.move(); Melon.move(); }