float dropX = 200; float dropY = 90; float speed = 0; float grav = 0.2; float rise = 400; //level of the water float dropsize = 0.25; // controls drop size PImage a; //the water image PImage b; //the faucet image void setup() { size (400,400); framerate(100); background(255); a = loadImage("water.gif"); b = loadImage("faucet.gif"); smooth(); } void draw(){ dropY = dropY + speed; //moves the drops speed = speed + grav; //adds gravity to the drops background(255); stroke (155); fill (0,0,255); image(b,188,0); //draws the faucet fill (200); rect (0,90,400,310); fill (0,0,255); line (0,90,400,90);//draws the edge of the pool ellipseMode (CENTER); ellipse (dropX,dropY,(75*dropsize),(90*dropsize)); //draws the big blue part of the water drops triangle (dropX-(25*dropsize),dropY-(34*dropsize),dropX+(25*dropsize),dropY-(34*dropsize),dropX,dropY-(74*dropsize)); //draws the "peak" of the water drops fill(255); ellipse (dropX-(20*dropsize),dropY+(6*dropsize),(10*dropsize),(30*dropsize));//draws the white hightlight of the water drops image(a, 0, rise); if (dropY > rise) { // creates new drops dropY = 90; rise--; if (mouseX >= 200 && mouseX <= 350 && mouseY <= 70 && mousePressed) { // increases drop speed when the mouse is pressed on the faucet speed = speed + grav; } else { // stabilizes drop speed speed = 0; } } if (rise < 100) { //caps the water level rise = 100; dropY = 400; } }