import krister.Ess.*; Channel mySound; int rows = 1; //number of rows of squares to draw in the background int cols = 1; //number of columns of squares to draw in the background int oil = 15; //number of oil drops to draw in the foreground int num = 60; float mx[] = new float[num]; float my[] = new float[num]; int[][] aSquare = new int[rows*cols][3]; //array to hold x, y, and shade values for each circle int[][] aOil = new int[oil][4]; //array to hold starting x, y, and size and speed scale values for each cheese Square[] oSquare = new Square[rows*cols]; //array to hold each circle object Oil[] oOil = new Oil[oil]; //array to hold each cheese object myVegetable vg1; // declare myVegetable object PImage img1; PImage img2; PImage img3; PImage img4; PImage img5; PImage img6; boolean mouseWasPressed = false; void setup() { size(500,500); framerate(10); Ess.start(this); fillSquareArray(); fillOilArray(); makeObjects(); smooth(); img1 = loadImage("lettuce.gif"); img2 = loadImage("carrot.gif"); img3 = loadImage("tomato.gif"); img4 = loadImage("onion.gif"); img5 = loadImage("pepper.gif"); vg1 = new myVegetable(35, 10,5,30,color(0,0,255)); mySound = new Channel ("salad2.wav"); mySound.volume(.5); mySound.play(Ess.FOREVER); } void draw() { for(int i=0;i= 30) { Increment = -2; } } } // set up class for myVegetable class myVegetable { //Declare variables for myVegetable object int mouseX; // horizontal position (x-axis) int mouseY; // vertical position (y-axis) int yspeed; // how to move along x-axis int vegetable_size; // size of vegetable // color vegetable_color; // what color // instantiate/constuct the myVegetable object myVegetable (int xp, int yp, int xs, int vs, color vc) { mouseX = xp; // set initial x position mouseY = yp; // set intial y position yspeed = xs; // set intial speed on x-axis vegetable_size = vs; // set size of vegetable } void draw_vegetable() { rectMode(CENTER); image(img1,mouseX, mouseY+370, vegetable_size*2, vegetable_size*2); image(img2,mouseX+100,mouseY+370,20*2,40*2); image(img3,mouseX+200,mouseY+370,30*2,30*2); image(img4,mouseX+300,mouseY+320,20*2,80*2); image(img5,mouseX+400,mouseY+370,20*2,50*2); } // move along the y-axis // if (mousePressed == true){ void ymove() { mouseY += yspeed; if ((mouseY > height) || (mouseY < 260)) { yspeed *= -1; } } } // end of class myVegetable class Oil { int xPos; int yPos; int Scale; int Speed; int xAdjust; Oil(int x, int y, int _s, int _d) { xPos = x; yPos = y; Scale = _s; Speed = _d; if(noise(yPos)<.4) { xAdjust = 0; } else if(noise(yPos)>.6) { xAdjust = 0; } else { xAdjust = 0; } } void refresh() { stroke(#737F14); fill(#737F14); ellipse(xPos, yPos, Scale*2, Scale*2); fill(#FFFFFF); //rect(xPos+40,yPos+60,Scale,Scale); yPos = yPos+Speed; if((dist(xPos, yPos, mouseX, mouseY) > 100) && (xPos <= mouseX)) { xPos = xPos + 5; } else if((dist(xPos, yPos, mouseX, mouseY) > 100) && (xPos > mouseX)) { xPos = xPos - 5; } if((dist(xPos, yPos, mouseX, mouseY) > 100) && (yPos <= mouseY)) { yPos = yPos + 5; } else if((dist(xPos, yPos, mouseX, mouseY) > 100) && (yPos > mouseY)) { yPos = yPos - 5; } xPos = xPos + xAdjust; if(yPos-Scale*3 >= height) { yPos = 100; xPos = int(random(0, width)); Scale = int(random(2, 8)); Speed = int(random(2, 6)); } } }