Your browser does not support the canvas tag.

previous        Show / Hide Source        Download        next
//Second Assignment
// Title: EMOJI MAKER
// Welcome to Emoji Maker where you can do just that, customize you own emoji1
// I mean where else can you make a blushing pile of poop with a top hat?
// Click the buttons to choose a emoji body and face 
// Clicking the red button changes the wall colour!
// clixk the window to go through the day and build your emoji during the night!
// Dylan M.


// My Variables 
boolean regular = false;
boolean poop = false;
boolean mad = false;
boolean smile = false;
boolean tongue = false;
boolean blush = false;
boolean hat = false;
boolean window = false;
boolean buttonPressedThisFrame= false;
float cases = 0;
int r = 0;
int g = 0;
int b = 0;


void setup() {
  size(400, 400);
}

void draw() {

  //User Defined Functions
  changeBG();
  displayFloor();
  displayCases();
  displayCabinet();
  displayWindow();
  displayCounter();
  displayFlask();
  regularMoji();
  poopMoji();
  madMoji();
  smileyFace();
  tongueOut();
  blushing();
  topHat();
  ButtonP();
  ButtonR();
  ButtonM();
  ButtonS();
  ButtonT();
  ButtonB();
  ButtonTH();
  ButtonRandom();
}

// Background and other Main Components

//Floor
void displayFloor() {
  stroke(120, 60, 50);
  fill(120, 60, 50);
  rect(0, 280, width, 60);
}

//Cabinet With Test Tubes on Top

void displayCabinet() {
  stroke(220);
  fill(255);
  rect(300, 280, 100, 40);
  quad(300, 280, 280, 260, 280, 300, 300, 320);
  quad(300, 280, 280, 260, 400, 260, 400, 280);

  // Test Tubes

  stroke(0);
  fill(255);
  rect(310, 240, 10, 30, 10);
  rect(330, 240, 10, 30, 10);
  rect(350, 240, 10, 30, 10);

  stroke(255, 0, 0);
  fill(255, 0, 0);
  rect(312, 248, 6, 20, 10);

  stroke(0, 255, 0);
  fill(0, 255, 0);
  rect(332, 248, 6, 20, 10);

  stroke(0, 0, 255);
  fill(0, 0, 255);
  rect(352, 248, 6, 20, 10);
}

// Window that changes from day to night

void displayWindow() {

  // Window During The Day

  if (window == false) {

    stroke(0);
    fill(175, 215, 250);
    rect(220, 100, 160, 70);

    stroke(0);
    fill(255);

    quad(220, 170, 380, 170, 370, 180, 230, 180);
  }

  // Window During The Night 

  if (window == true) {
    stroke(0);
    fill(10, 35, 65);
    rect(220, 100, 160, 70);
    stroke(0);
    fill(235);

    quad(220, 170, 380, 170, 370, 180, 230, 180);


    stroke(255);
    fill(255);

    ellipse(340, 130, 30, 30);
  }

  if (mouseX>=220 && mouseX<=380 && mouseY>=100 && mouseY<= 160 && mousePressed && buttonPressedThisFrame== false) {
    buttonPressedThisFrame = true;
    if (window==true) {
      window =false;
    } else {
      window=true;
    }
  }
}
void displayCounter() {

  // Counter where the Flask is Placed

  stroke(0);
  fill(255);

  rect(-10, 340, width*2, 60);
}

void displayFlask() {

  // Flask in which you make your Emoji 

  stroke(100);
  fill(190, 225, 255);
  rect(140, 220, 120, 160, 10);

  stroke(100);
  fill(165, 200, 255);
  ellipse(200, 220, 120, 20);
}

//Loop of Cabinets with Glass windows

void displayCases() {
  cases = 0;
  while ( cases< width) {
    cases = cases + 80;

    stroke(0);
    fill(145, 100, 50);

    rect(cases, 200, 60, 90);

    stroke(190, 240, 230);
    fill(190, 240, 230);

    rect(cases+10, 210, 40, 70);

    stroke(120, 65, 10);
    fill(120, 65, 10);
    rect(cases+10, 230, 40, 10);
    rect(cases+10, 260, 40, 10);
  }
}

// Emojis

// Regular Yellow Emoji

void regularMoji() {
  if (regular == true) {
    stroke(250, 190, 20);
    fill(252, 215, 50);
    ellipse(200, 320, 80, 80);
  }
}

// Poop Emoji

void poopMoji() {
  if (poop == true) { 
    stroke(65, 25, 5);
    fill(130, 65, 20);

    rect(150, 330, 100, 20, 10);
    rect(165, 310, 70, 20, 10);
    rect(175, 295, 50, 15, 10);
    rect(185, 285, 30, 10, 10);
  }
}

// Angry Red Emoji

void madMoji() {
  if (mad == true) {    
    stroke(185, 40, 30);
    fill(215, 65, 55);
    ellipse(200, 320, 80, 80);
  }
}
//Faces

//Regular Happy Smiling Face

void smileyFace() {

  if (smile == true) {
    stroke(0);
    fill(255);
    rect(180, 290, 15, 30, 10);
    rect(205, 290, 15, 30, 10);

    stroke(0);
    fill(0);
    rect(182, 295, 12, 20, 10);
    rect(207, 295, 12, 20, 10);

    stroke(0);
    fill(255);
    arc(200, 325, 30, 30, 0, PI);
  }
}

// Crazy with Tongue Sticking Out

void tongueOut() {

  if (tongue == true) { 
    stroke(0);
    fill(0); 
    rect(175, 310, 20, 3, 5);

    stroke(0);
    fill(255);
    rect(205, 290, 15, 30, 10);

    stroke(0);
    fill(0);
    rect(207, 295, 12, 20, 10);

    stroke(0);
    fill(0);
    arc(200, 325, 30, 30, 0, PI);

    stroke(0);
    fill(0);
    arc(200, 325, 30, 30, 0, PI);

    stroke(245, 130, 120);
    fill(245, 130, 120);
    rect(195, 330, 12, 30, 10);
    rect(195, 330, 12, 20);

    stroke(140, 40, 30);
    fill(140, 40, 30);
    line(201, 330, 201, 355);
  }
}

//Blushing Face

void blushing() { 


  if (blush == true) {

    stroke(0);
    fill(255);
    rect(183, 300, 10, 20, 10);
    rect(208, 300, 10, 20, 10);

    stroke(242, 133, 133);
    fill(242, 133, 133);
    rect(220, 320, 20, 5, 10);
    rect(160, 320, 20, 5, 10);

    stroke(0);
    fill(255);
    arc(200, 325, 30, 30, 0, PI);
  }
}

// Gentlemans Top Hat
void topHat() {
  if (hat == true) {
    stroke(0);
    fill(0);
    rect(171, 283, 55, 7, 5);


    stroke(0);
    fill(0);
    rect(178, 240, 40, 35);

    stroke(255);
    fill(255);
    rect(178, 275, 40, 8);
  }
}
// Buttons

//Regular Face Button

void ButtonR() {
  stroke(20);
  fill(20);  
  rect(122, 42, 40, 40);

  stroke(200);
  fill(100);  
  rect(120, 40, 40, 40);


  if (mouseX>=120 && mouseX<=160 && mouseY>=40 && mouseY<=80 && mousePressed) {
    regular = true;
    mad = false;
    poop = false;
  }
}

// Poop Face Button 

void ButtonP() {
  stroke(20);
  fill(20); 
  rect(202, 42, 40, 40);


  stroke(200);
  fill(100);  

  rect(200, 40, 40, 40);

  if (mouseX>=200 && mouseX<=240 && mouseY>=40 && mouseY<=80 && mousePressed) {

    poop = true;
    mad = false;
    regular = false;
  }
}

// Mad Face Button 

void ButtonM() { 
  stroke(20);
  fill(20); 

  rect(282, 42, 40, 40);

  stroke(200);
  fill(100); 

  rect(280, 40, 40, 40);

  if (mouseX>=280 && mouseX<=320 && mouseY>=40 && mouseY<=80 && mousePressed) {
    mad = true;
    regular = false;
    poop = false;
  }
}

// Regular Smile Button 

void ButtonS() { 
  stroke(20);
  fill(20); 

  rect(42, 122, 40, 40);

  stroke(200);
  fill(100); 

  rect(40, 120, 40, 40);

  if (mouseX>=40 && mouseX<=80 && mouseY>=120 && mouseY<=160 && mousePressed) {
    smile = true;
    tongue = false;
    blush = false;
  }
}

// Smile with Tongue Out 

void ButtonT() {
  stroke(20);
  fill(20); 
  rect(42, 202, 40, 40);

  stroke(200);
  fill(100); 

  rect(40, 200, 40, 40);

  if (mouseX>=40 && mouseX<=80 && mouseY>=200 && mouseY<=240 && mousePressed) {
    tongue = true;
    smile = false;
    blush = false;
  }
}

// Blushing Smile

void ButtonB() {
  stroke(20);
  fill(20); 

  rect(42, 282, 40, 40);

  stroke(200);
  fill(100); 

  rect(40, 280, 40, 40);

  if (mouseX>=40 && mouseX<=80 && mouseY>=280 && mouseY<=320 && mousePressed) {
    blush= true;
    smile = false;
    tongue = false;
  }
}

// Button that activates "top" secret Top Hat. See what I did there? Haha.. 

void ButtonTH() {
  stroke(20);
  fill(20); 

  rect( 42, 42, 40, 40);

  stroke(200);
  fill(100);
  rect(40, 40, 40, 40);


  if (mouseX>=40 && mouseX<=80 && mouseY>=40 && mouseY<=80 && mousePressed && buttonPressedThisFrame == false) {
    buttonPressedThisFrame = true;
    if (hat==true) {
      hat =false;
    } else {
      hat=true;
    }
  }
}

// When the mouse is released it will make whatever was pressed stay rather than blinking on screen and leaving 
void mouseReleased() { 
  buttonPressedThisFrame = false;
}


// Random Button 

void ButtonRandom() {
  stroke(110, 15, 25);
  fill(110, 15, 25);
  ellipse(142, 142, 40, 40);

  stroke(255, 40, 40);
  fill(255, 40, 40);
  ellipse(140, 140, 40, 40);
}

//Color Changing Wall 
void changeBG() {

  if (mouseX>=120 && mouseX<=160 && mouseY>=120 && mouseY<=160 && mousePressed && buttonPressedThisFrame == false) {
    buttonPressedThisFrame = true;

    r=int(random(0, 255));
    g=int(random(0, 255));
    b=int(random(0, 255));
    background(r, g, b);
  }
}


//Thanks for Building your emoji!