Your browser does not support the canvas tag.

previous        Show / Hide Source        Download        next
/* Sandwich Maker WIP
 Calvin Leveille
 
 The goal of this program was to be able to assemble a sandwich using bread, peanut butter, and jam on a plate.
 The bread and jam could be clicked and dragged around to build the sandwich. However, it appears I went a little
 over my head at the last minute, having dedicated too much of my time over the past few weeks to my other
 assignments that were due before reading week. Because I was unable to overcome the many obstacles I faced all at once 
 undertaking this project, this program functionally doesn't do anything at all right now, but I figured I might as well 
 submit everything that I had instead of submitting nothing at all. */
// array of sandwich parts
Sandwich[] Bread;

void setup() {
  frameRate(60);
  size(800, 600);
  rectMode(CENTER);
  ellipseMode(RADIUS);
  noStroke();


  Bread=new Sandwich[9];
  //Sandwich[] Jam;
  //Sandwich[] Pbutter;

  // creates 9 bread objects

  Bread[0]= new Sandwich(new PVector(125, 80), color(180, 55, 55));
  Bread[1]= new Sandwich(new PVector(125, 105), color(180, 55, 55));
  Bread[2]= new Sandwich(new PVector(125, 130), color(180, 55, 55));
  Bread[3]= new Sandwich(new PVector(125, 155), color(180, 55, 55));
  Bread[4]= new Sandwich(new PVector(125, 180), color(180, 55, 55));
  Bread[5]= new Sandwich(new PVector(125, 205), color(180, 55, 55));
  Bread[6]= new Sandwich(new PVector(125, 230), color(180, 55, 55));
  Bread[7]= new Sandwich(new PVector(125, 255), color(180, 55, 55));
  Bread[8]= new Sandwich(new PVector(125, 280), color(180, 55, 55));
}


void draw() {
  // draw background
  fill(179, 227, 217);
  rect(width / 2, height / 2, 800, 600);
  fill(139, 135, 124);

  rect(400, 350, 800, 500);

  // draw plate
  fill(101, 201, 177);
  ellipse(400, 515, 230, 80);
  fill(43, 170, 163);
  ellipse(400, 515, 180, 50);
  fill(101, 201, 177);
  ellipse(400, 515, 175, 45);

  // draw bread
  for (int x=0; x<Bread.length; x++) {
    Bread[x].drawBread();
  }
}
class Sandwich {
  PVector position; 
  boolean click;
  // sets variables for drawing sandwich parts
  int btopwidth=210;
  int btopheight=60;
  int bcrustwidth=210;
  int bcrustheight=80;
  int spreadwidth=70;
  int spreadheight=25;

  //  
  Sandwich(PVector pos, color colour) {
    this.position=pos;
    this.click=false;
  }

  //draw bread
  void drawBread() {
    if (click) {
      this.position = new PVector(mouseX, mouseY);
    }
    fill(255, 226, 147);
    rect(position.x + 10, position.y + 10, bcrustwidth, bcrustheight);
    fill(139, 102, 67);
    rect(position.x, position.y, btopwidth, btopheight);
  }

  //draw jam
  void drawJam() {
    if (click) { 
      this.position = new PVector(mouseX, mouseY);
    }
    fill(232, 33, 73);
    ellipse(position.x, position.y, spreadwidth, spreadheight);
  }

  // draw peanut butter
  void drawPbutter() {
    if (click) {
      this.position = new PVector(mouseX, mouseY);
    }
    fill(227, 169, 44);
    ellipse(position.x, position.y, spreadwidth, spreadheight);
  }

  PVector getPosition() {
    return this.position;
  }

  void setPosition(PVector position) {
    this.position = position;
  }

  boolean getClick() { 
    return this.click;
  }

  void setClick(boolean click) {
    this.click = click;
  }
}
class table_objects {
  PVector position;
  boolean clicked;

  table_objects() {
  }
}