Your browser does not support the canvas tag.

previous        Show / Hide Source        Download        next
/////////////////////////////////////////////////////////
//Morning Coffee, by Halie Towns. 
//Aspects used from Car design by Ossy Meza Brun. 
//Busy 9-5's walking by for their morning coffee!!
//Click to open for business!!
////////////////////////////////////////////////////////

int numberOfMen=5;
Man[] men = new Man [numberOfMen];

Coffee cup0;
Coffee cup1;
Coffee cup2;
Coffee cup3;
Coffee cup4;
Coffee cup5;

void setup() {
  size(800, 300);
  noStroke();
  rectMode(CENTER);

  cup0=new Coffee (random(270, 750), random(178, 193));
  cup1=new Coffee(random(270, 750), random(178, 193));
  cup2=new Coffee(random(270, 750), random(178, 193));
  cup3=new Coffee (random(270, 750), random(178, 193));
  cup4=new Coffee(random(270, 750), random(178, 193));
  cup5=new Coffee(random(270, 750), random(178, 193));

  instantiateMen();
}

void instantiateMen() {
  for (int i=0; i<men.length; i++) {
    men[i]=new Man(random(-40, 200), 200, random(1, 3), 0);
  }
}

void draw() {
  background(252, 193, 91);
  noStroke();
  rectMode(CORNERS);
  ////////////////////////////////////// 
  //Still Background Stuff
  wallDecoration(); 
  backCounter();
  barista();
  lightInBack();
  frontCounter(); 
  openSign();
  instructions();
  orderUp();
  openForBusiness();
}

void frontCounter() {
  //Front Counters
  stroke(96, 54, 19);
  strokeWeight(2);
  fill(120, 69, 25);

  //Lower Front Counter
  rect(250, 175, 800, 800); 
  strokeWeight(0.5);
  fill(132, 76, 28);
  rect(250, 225, 800, 800); 
  fill(136, 78, 29);
  rect(250, 250, 800, 800); 
  fill(120, 69, 25);
  rect(250, 275, 800, 800); 

  //Higher Front Counter
  fill(120, 69, 25); 
  rect(0, 50, 275, 800); 
  fill(132, 76, 28);
  rect(0, 75, 275, 800); 
  fill(136, 78, 29);
  rect(0, 100, 275, 800);
  fill(132, 76, 28);
  rect(0, 125, 275, 800); 
  fill(120, 69, 25);
  rect(0, 150, 275, 800); 
  fill(120, 69, 25);
  rect(0, 175, 275, 800); 
  fill(120, 69, 25);
  rect(0, 200, 275, 800); 
  fill(132, 76, 28);
  rect(0, 225, 275, 800); 
  fill(136, 78, 29);
  rect(0, 250, 275, 800); 
  fill(137, 79, 29);
  rect(0, 275, 275, 800); 

  //Lower Front Counter Top 
  strokeWeight(2);
  fill(137, 79, 29);
  rect(265, 200, 800, 215);
  quad(275, 175, 265, 200, 805, 200, 805, 175);

  //Higher Front Counter Top
  rect(0, 50, 285, 65);
}

void barista() {
  rectMode(CENTER);
  stroke(0);
  strokeWeight(1);
  //Head
  fill(200);
  ellipse(500, 100, 50, 50);
  noStroke();
  fill(200);
  ellipse(500, 105, 30, 30);


  stroke(0);
  strokeWeight(1);
  fill(230);
  rect(500, 200, 70, 150, 40, 40, 10, 10);
  fill(0, 255, 0);
  rect(480, 151, 10, 50, 90);
  rect(520, 151, 10, 50, 90);
  rect(500, 240, 50, 150);

  if (mousePressed==true) {
    noStroke();
    //Smile
    fill(255);
    ellipse(500, 105, 30, 30);
    fill(200);
    rect(500, 100, 30, 30);
  }

  rectMode(CORNERS);
}

void backCounter() {
  stroke(67, 36, 12);
  strokeWeight(2);
  //Back Counter
  fill(87, 48, 17);
  rect(250, 100, 800, 800);
  fill(72, 39, 13);
  rect(250, 100, 800, 160);
  //Back Counter Top
  fill(96, 54, 19);
  rect(250, 100, 800, 145);
  rect(250, 100, 800, 125);
}

void wallDecoration() {
  fill(248, 190, 87);
  rect(0, 20, 800, 800);
  fill(236, 182, 79);
  rect(0, 60, 800, 800);

  noStroke();
  fill(236, 182, 79);
  rect(405, -20, 603, 55);
  rect(680, -20, 810, 39);

  stroke(230, 166, 72);
  strokeWeight(1);
  fill(25);
  rect(400, -20, 600, 50);
  rect(675, -20, 810, 35);
}

void lightInBack() {
  fill(0, 10);
  rect(0, 0, 800, 800);

  noStroke();
  fill(255, 20);
  rect(50, -10, 300, 800);
  rect(320, -10, 600, 800);
  rect(620, -10, 810, 800);
}

void openSign() {
  noStroke();
  rectMode(CENTER);
  fill(15, 50);
  rect(505, 250, 100, 50);
  fill(250);
  rect(500, 250, 100, 50);
  stroke(255, 0, 0);
  fill(255, 0, 0);
  ellipse(500, 250, 30, 30);
  if (mousePressed == true) {
    stroke(0, 255, 0);
    fill(0, 255, 0);
    ellipse(500, 250, 30, 30);
  }
}
void instructions() {
  noStroke();
  fill(15, 50);
  rect(155, 145, 100, 100, 10);
  fill(15);
  rect(150, 142, 100, 100, 10);

  //Coffee on sign
  rectMode(CENTER);
  fill(255);
  ellipse(150, 150, 20, 10);
  quad(150 - 10.5, 150, 150 - 11.4, 150 - 20, 150 + 11.4, 150 - 20, 150 + 10.5, 150);
  ellipse(150, 150 - 20, 25, 10);
  fill(87, 48, 17);
  ellipse(150, 150 - 20, 20, 5);
  //Coffee Steam
  stroke(200);
  strokeWeight(1);
  line(150, 150 - 23, 150, 150 - 45 );
  line(150 + 4, 150 - 23, 150 + 4, 150 - 40);
}
void orderUp() {
  if (mousePressed == true) {
    cup0.displayCup();
    cup1.displayCup();
    cup2.displayCup();
    cup3.displayCup();
    cup4.displayCup();
    cup5.displayCup();
  } else {
    cup0=new Coffee (random(270, 750), random(178, 193));
    cup1=new Coffee(random(270, 750), random(178, 193));
    cup2=new Coffee(random(270, 750), random(178, 193));
    cup3=new Coffee (random(270, 750), random(178, 193));
    cup4=new Coffee(random(270, 750), random(178, 193));
    cup5=new Coffee(random(270, 750), random(178, 193));
  }
}

void openForBusiness() {
  //Man update
  for (int i=0; i<men.length; i++) {
    men[i].update();
  }
  //Man display
  for (int i=0; i<men.length; i++) {
    men[i].display();
  }
}
class Coffee {

  float positionX;
  float positionY;

  color cColor;
  
    Coffee(float x, float y) {
    positionX=x+3;
    positionY=y+2;
    setRandomCupColor();
  }


  void setRandomCupColor() {
    cColor=color(random(255), random(255), random(255));
  }
  

  void displayCup() {
    noStroke();
    rectMode(CENTER);

    //Coffee Cup
    fill(cColor);
    ellipse(positionX, positionY, 20, 10);
    quad(positionX - 10.5, positionY, positionX - 11.4, positionY - 20, positionX + 11.4, positionY - 20, positionX + 10.5, positionY);
    ellipse(positionX, positionY - 20, 25, 10);
    fill(87, 48, 17);
    ellipse(positionX, positionY - 20, 20, 5);
    //Coffee Steam
    stroke(200);
    strokeWeight(1);
    line(positionX, positionY - 23, positionX, positionY - 45 );
    line(positionX + 4, positionY - 23, positionX + 4, positionY - 40);
    rectMode(CORNERS);
  }
}
class Man {
  PVector position=new PVector();
  PVector velocity=new PVector();
  
  color manColor;
  color sColor;

  Man(float x, float y, float velocityX, float velocityY) {
    position.x=x;
    position.y=y;
    velocity.x=velocityX;
    velocity.y=velocityY;
    setRandomManColor();
    setRandomSkinColor();
  }

  void update() {
    position. add (velocity);

    if (position.x>width+50) {
      position.x=-50;
      position.y=200;
      setRandomManColor();
      setRandomSkinColor();
    }
  }

  void setRandomManColor() {
    manColor=color(random(255), random(255), random(255));
  }
    void setRandomSkinColor() {
    sColor=color(random(255), random(255), random(255));
  }


  void display() {   
    rectMode(CENTER);
    stroke(0);
    strokeWeight(1);
    fill(manColor);
    rect(position.x, position.y +25, 55, 165, 90, 30, 5, 5); //Body
    fill(sColor);
    ellipse(position.x + 2, position.y - 82, 55, 55);//Head 
    fill(0);
    rect(position.x+18, position.y + 64, 5, 20);//Briefcase Handle Left
    rect(position.x-18, position.y +64, 5, 20);//Briefcase Handle Right
    rect(position.x, position.y +55, 40, 5);//Briefcase Handle top
    rect(position.x, position.y +90, 100, 50);//Briefcase
    fill(sColor);
    ellipse(position.x, position.y +50, 25, 25);//Hand
    fill(manColor);
    rect(position.x, position.y + 5, 25, 85, 90, 90, 0, 0);//Sleeve
  }
  
}