//Untitled //Chavaiz Amil //click for the ball to jump to cursor and drop ?? //this is very poorly done so i apologize to you for having to endure it :( //and to myself for the disappointment //FeelsBadMan //state boolean a = false; boolean cover = false; boolean locked = false; color randomColor; float xPos; float yPos; float speed; float gravity; float cx; float cy; int cs = 50; float cdifx = 0; float cdify = 0; //setup void setup() { size(400, 400); frameRate(60); smooth(); noStroke(); ellipseMode(CENTER); rectMode(CENTER); //state variables xPos = 200; yPos = 0; speed = 0; gravity = 0.4; randomColor = color(random(255), random(255), random(255)); cx = xPos-120; cy = yPos; } //draw function void draw() { frameRate(60); drawBg(); drawTable(); drawCandle(); addGrav(); tableStop(); boundaries(); //moccheck(); drawCircles(); mouseBall(); noStroke(); } //void mousePressed() { // //cirOverCheck(); // //if (mousePressed){ // // speed += -.5; // // cx = mouseX; // // yPos = mouseY; // // if (mouseX>cx){ // // speed += .5; // // } // //} //} //void mouseDragged() { // //cirLockCheck(); //} //void mouseReleased() { // //locked = false; //} /////////////// ////D R A W//// /////////////// //draw background void drawBg() { background(75); fill(randomColor); for(int y=0; y < height; y += 17){ for(int x=0; x < width; x += 17){ rect( x, y, 5,5); } } } //draw table void drawTable() { fill(82, 54, 27); rect(200, 350, width, 65); fill(49, 29, 14); rect(200, 383, width, 20); } ////draw candle void drawCandle() { //candle fill(238, 232, 170, 230); rect(200, 220, 10, 40, 250); //band fill(188, 198, 204); rect(200, 220, 14, 5, 253); fill(255, 185, 0, 100); rect(200, 219, 14, 3, 250); //fire a=true; if (a) { frameRate(3); fill(random(255, 255), random(165, 255), random(0, 0)); ellipse(200, 198, 5+sin(millis()/150)*1, 10+sin(millis()/150)*1); } //glow fill(255, 255, 204, 70); ellipse(200, 200, 350+sin(millis()/150)*6, 340+sin(millis()/150)*6); //glow loop //int i = 0; //while (i < 340){ // i = i+50; // fill(255,255,204,70); // ellipse(200, 200, i, i); // if (i >= 340){ // i = -50; // } //} //int i = 250; //fill(255, 255, 204, 70); //ellipse(200, 200, i, i); //if (i >= 250) { // i = i+25; //} //if (i <= 350) { // i = i-25; //} } //draw circles void drawCircles() { stroke(0, 0, 0); strokeWeight(1.5); //left circle fill(randomColor); ellipse(cx, yPos, cs, cs); } //apply gravity void addGrav() { frameRate(45); yPos = yPos + speed; speed = speed + gravity; } //Stop ball once at the table void tableStop() { if ( speed < 0.65 && yPos > height-75) { speed = -0.65; gravity = 0.4; } else if (yPos > height-75) { speed = speed * -0.65; } } //dont allow ball off screen void boundaries() { if (cx>width-12) { speed = speed * -.65; cx=width-12; } else if (cx<12) { speed = speed * -.65; cx=12; } } //draw ball to mouse pos void mouseBall() { if (mousePressed) { speed += -.5; cx = mouseX; yPos = mouseY; if (mouseX>cx) { speed += .5; } } } /////////////// ////D R A G//// /////////////// //void moccheck() { // if (mouseX > cx-cs && mouseX < cx+cs && // mouseY > yPos-cs && mouseY < yPos+cs) { // cover = true; // if (!locked) { // stroke(255); // //fill(180,0,0); // } // } else { // stroke(153); // //fill(153); // cover = false; // } //} //void cirOverCheck() { // if (cover) { // locked = true; // //fill(255, 255, 255); // } else { // locked = false; // } // cdifx = mouseX-cx; // cdify = mouseY-yPos; //} //void cirLockCheck() { // if (locked) { // cx = mouseX-cdifx; // cy = mouseY-cdify; // } //}