Your browser does not support the canvas tag.

previous        Show / Hide Source        Download        next
//due thurs 10pm
//Tiberiu Leonov

void setup() {
  //make a window sized 400 by 400
  size(400, 400);
  //set framerate
  frameRate(60);
}


void draw() {

  //background wall 
  //turns to night on click
  background(232-(mouseButton*2), 167-(mouseButton*2), 113-(mouseButton*2));
  noStroke();
  fill(255-(mouseButton*2), 247-(mouseButton*2), 228-(mouseButton*2));
  rect(0, 0, 400, 210);

  //ping pong table stand
  strokeWeight(6);
  stroke(150-(mouseButton*2), 150-(mouseButton*2), 150-(mouseButton*2));
  line(62, 310, 120, 235);
  line(337, 315, 290, 255 );
  fill(150-(mouseButton*2), 150-(mouseButton*2), 150-(mouseButton*2));
  stroke(100-(mouseButton*2), 100-(mouseButton*2), 100-(mouseButton*2));
  strokeWeight(0.5);
  rect(60, 270, 6, 80, 3);
  rect(340, 270, -6, 80, 3);
  rect(62, 310, 277, 5, 3);
  
  //ping pong table top
  stroke(255-(mouseButton*2), 255-(mouseButton*2), 255-(mouseButton*2));
  strokeWeight(2);
  fill(63-(mouseButton*2), 112-(mouseButton*2), 255-(mouseButton*2));
  quad (25, 275, 100, 200, 300, 200, 375, 275); 

  //ping pong table markings
  fill(255-(mouseButton*2));
  quad (195, 275, 199, 200, 201, 200, 205, 275 );

  //ping pong table net
  fill(50-(mouseButton*2), 50-(mouseButton*2), 50-(mouseButton*2), 70);
  quad (55, 233, 55, 215, 345, 215, 345, 233);

  //ping pong ball shadow
  noStroke();
  fill(50-(mouseButton*2), 50-(mouseButton*2), 50-(mouseButton*2), 70);
  ellipse(200+(mouseX-200)/1.3, 205+(mouseY)/6.3, 6+(mouseY/80), 6+(mouseY/150));

  //ping pong ball
  stroke(0, 0, 0);
  fill(255, 255, 255);
  strokeWeight(0.5);
  ellipse(200+(mouseX-200)/1.3, ((mouseY-120)*(mouseY-120)/1000)+190, 6+(mouseY/80), 6+(mouseY/80));
  
  //overhead light turns on with click
  noStroke();
  fill (255,255,0, mouseButton*1.5);
  triangle(200,0, 65 , 233, 335, 233);
  arc(200, 233, 270, 35, 0, PI);
  fill(0);
  triangle(200, -20, 150, 30, 250, 30);

  //paddle handle
  stroke (255-(mouseButton*2), 204-(mouseButton*2), 102-(mouseButton*2));
  strokeWeight(12.0);
  strokeCap(ROUND);
  line(mouseX, 205+(mouseY)/4,    ((mouseX-200)/1.15)+200, 205+(mouseY)/4);

  //color changing paddle depending on direction
  fill(sqrt(mouseX-200)*255, 0, 0);
  noStroke();
  arc(mouseX, 205+(mouseY)/4
    , (40+ 10*abs(mouseX-200)/200) * abs(mouseX-200)/200, 50- 10*abs(mouseX-200)/200, (PI-QUARTER_PI)+(mouseX-200)/(PI*40), (2*PI+QUARTER_PI)+(mouseX-200)/(PI*40)); 

  //main stick figure semi transparent to see the ball and make movement clear
  fill(0, 0, 0, 70);
  noStroke();

  //head
  ellipse( ((mouseX-200)/3)+200, 200+abs(mouseX-200)/6, 50, 50); 

  //body
  stroke(0, 0, 0, 70);
  strokeWeight(12.0);
  strokeCap(ROUND);
  line(((mouseX-200)/3)+200, 200+abs(mouseX-200)/6, ((mouseX-200)/8)+200, 300 +abs(mouseX-200)/6); 

  //left arm
  line (((mouseX-200)/6)+170, ((mouseY-200)/7 ) +280, ((mouseX-200)/3.5)+200, 225+abs(mouseX-200)/6 );
  line (((mouseX-200)/6)+170, ((mouseY-200)/7 ) +280, ((mouseX-200)/2.5)+170, ((mouseY-200)/4 ) +300 );

  //right arm
  line (((mouseX-200)/1.7)+200, ((mouseY-200)/6 ) +257, ((mouseX-200)/3.5)+200, 225+abs(mouseX-200)/6 );
  line (((mouseX-200)/1.7)+200, ((mouseY-200)/6 ) +257, ((mouseX-200)/1.15)+200, 205+(mouseY)/4 );
  
  //left leg
  line (((mouseX-200)/6)+170, 400, ((mouseX-200)/8)+200, 300 +abs(mouseX-200)/6); 
 
  //right leg
  line (((mouseX-200)/1.7)+200, 400, ((mouseX-200)/8)+200, 300 +abs(mouseX-200)/6); 
  
  
  //clock which moves faster on click
  stroke(0);
  strokeWeight(2);
  fill(255-(mouseButton*2));
  ellipse(100, 50, 40, 40);
  line(100, 50, 100+ (cos(frameCount*(0.2+mouseButton)))*15, 50+ (sin(frameCount*(0.2+mouseButton)))*15);
  line(100, 50, 100+ (cos(frameCount*(0.0167+mouseButton)))*8, 50+ (sin(frameCount*(0.0167+mouseButton)))*8);
  
  
}