{"id":69133,"date":"2021-11-15T09:44:54","date_gmt":"2021-11-15T14:44:54","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/?p=69133"},"modified":"2022-02-03T08:55:58","modified_gmt":"2022-02-03T13:55:58","slug":"project-11-3","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/2021\/11\/15\/project-11-3\/","title":{"rendered":"Project 11"},"content":{"rendered":"<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD HTML 4.0 Transitional\/\/EN\" \"http:\/\/www.w3.org\/TR\/REC-html40\/loose.dtd\">\n<html><body><p><a class=\"p5_sketch_link\" data-width=\"600\" data-height=\"450\" href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-content\/uploads\/2021\/11\/sketch-61.js\">sketch<\/a><iframe src=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-content\/plugins\/p5-embedder\/p5_iframe.html\" class=\"p5_exampleFrame\" width=\"600\" height=\"450\"><\/iframe><pre class=\"language-javascript\"><code class=\"p5_editor language-javascript\">\/\/ gnmarino\n\/\/ gia marino\n\/\/ section D\n\n\/\/ sushi conveyor belt animation\n\nvar sushis = [];\nvar nigiris = [];\n\nfunction setup() {\n    createCanvas(480, 320);\n\n}\n\nfunction draw() {\n    background(220);\n\n    \/\/ moves sushis and nigiris \n    moveDisplayOfSushiAndNigiri(); \n    \/\/ removes them if they go off the screen\n    removeOldSushiAndNigiri();\n    \/\/ adds new sushis and nigiris based off a low probability\n    addSushi_or_Nigiri();\n    \/\/ makes conveyour belt for sushi and nigiri to move on\n    conveyorBelt();\n}\n\nfunction removeOldSushiAndNigiri() {\n    var freshSushi = [];\n    var freshNigiri = [];\n\n    \/\/ if sushis are on the screen then put them in fresh sushi array\n    \/\/ if they are not on the screen then they will disappear because \n    \/\/ they won't be added to the new array\n    for (var i = 0; i &lt; sushis.length; i++){\n        if (sushis[i].x + sushis[i].sushiWidth &gt; 0) {\n            freshSushi.push(sushis[i]);\n        }\n    }\n\n    \/\/ same with nigiris\n    for (var i = 0; i &lt; nigiris.length; i++){\n        if (nigiris[i].x + nigiris[i].nigiriWidth &gt; 0) {\n            freshNigiri.push(nigiris[i]);\n        }\n    }\n\n    sushis = freshSushi;\n    nigiris = freshNigiri;\n}\n\nfunction moveDisplayOfSushiAndNigiri(){\n    for(var i = 0; i &lt; sushis.length; i ++){\n        sushis[i].move();\n        sushis[i].display();\n    }\n\n    for(var i = 0; i &lt; nigiris.length; i ++) {\n        nigiris[i].move();\n        nigiris[i].display();\n    }\n}\n\nfunction addSushi_or_Nigiri() {\n\n    \/\/ this is the probability of being added everytime code loops\n    var addSushiLikelihood = .005;\n    var addNigiriLikelihood = .004;\n\n    if(random(0, 1) &lt; addSushiLikelihood) {\n        sushis.push(makeSushi(width));\n    }\n\n    if(random(0, 1) &lt; addNigiriLikelihood) {\n        nigiris.push(makeNigiri(width +10));\n    }\n\n}\n\nfunction displayNigiri() {\n\n    push();\n    strokeWeight(2);\n    \/\/ these variables are used to make it easier to put the shapes together\n    var nigiriTop = 180-this.nigiriHeight   \/\/ conveyor belt is at 180\n    var nigiriMiddle = this.nigiriWidth\/2 + this.x\n\n    fill(247, 246, 241);    \/\/off-white\n    rect(this.x, nigiriTop, this.nigiriWidth, this.nigiriHeight);\n    fill(this.sashimiColor);\n    ellipse(nigiriMiddle, nigiriTop, this.nigiriWidth + 15, 40);\n\n    \/\/ this is to cover last ellipse so it looks more like shashimi\n    fill(247, 246, 241);    \/\/off-white\n    ellipse(nigiriMiddle, nigiriTop + 10, this.nigiriWidth, 25);\n    noStroke();\n    rect(this.x + 1, nigiriTop + 10, this.nigiriWidth-2, 15);\n    pop();\n\n}\n\nfunction displaySushi() {\n\n    \/\/ these variables are used to make it easier to put the shapes together\n    var sushiMiddle = this.sushiWidth\/2 + this.x\n    var sushiTop = 180-this.sushiHeight     \/\/ conveyor belt is at 180\n    push();\n    strokeWeight(2);\n    fill(this.wrapColor);\n    rect(this.x, sushiTop, this.sushiWidth, this.sushiHeight);\n    fill(247, 246, 241);    \/\/off-white\n    ellipse(sushiMiddle, sushiTop, this.sushiWidth, 25);\n    fill(this.fishColor);\n    ellipse(sushiMiddle, sushiTop, this.sushiWidth-20, 15);\n    pop();\n}\n\nfunction move_sushi_nigiri() {\n    this.x += this.speed;\n}\n\n\/\/ sushi object\nfunction makeSushi(originX) {\n    var sushi = {x: originX, \n                 sushiWidth: random(55, 100),\n                 sushiHeight: random(35, 70),\n                 wrapColor: color(0, random(100) , 0),\n                 fishColor: \n                 color(random(230, 260), random(145, 225), random(70, 160)),\n                 speed: -3,\n                 move: move_sushi_nigiri,\n                 display: displaySushi}\n    return sushi;\n}\n\n\/\/ nigiri object\nfunction makeNigiri(originX) {\n    var nigiri = {x: originX,           \/\/ don't know if i need to change that\n                 nigiriWidth: random( 70, 110),\n                 nigiriHeight: random( 15, 40),\n                 sashimiColor: \n                 color(random(230, 260), random(145, 225), random(70, 160)),\n                 speed: -3,\n                 move: move_sushi_nigiri,\n                 display: displayNigiri}\n    return nigiri;\n}\n\nfunction conveyorBelt() {\n\n    push();\n    fill(70);\n    rect(40, 185, 440, 150)\n    fill(180);\n    strokeWeight(5);\n    ellipse(30, 260, 150);\n    ellipse(450, 260, 150);\n\n    strokeWeight(12);\n    line(30, 335, 450, 335);\n    line(30, 185, 450, 185);\n    arc(30, 260, 150, 150, radians(90), radians(270), OPEN);\n    arc(450, 260, 150, 150, radians(-90), radians(90), OPEN);\n\n    pop();\n}\n\n<\/code><\/pre><\/p><\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>sketch \/\/ gnmarino \/\/ gia marino \/\/ section D \/\/ sushi conveyor belt animation var sushis = []; var nigiris = []; function setup() { createCanvas(480, 320); } function draw() { background(220); \/\/ moves sushis and nigiris moveDisplayOfSushiAndNigiri(); \/\/ removes them if they go off the screen removeOldSushiAndNigiri(); \/\/ adds new sushis and nigiris based &hellip; <a href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/2021\/11\/15\/project-11-3\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Project 11&#8221;<\/span><\/a><\/p>\n","protected":false},"author":658,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[115,58],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/69133"}],"collection":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/users\/658"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/comments?post=69133"}],"version-history":[{"count":3,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/69133\/revisions"}],"predecessor-version":[{"id":69542,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/69133\/revisions\/69542"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/media?parent=69133"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/categories?post=69133"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/tags?post=69133"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}