{"id":69520,"date":"2021-12-08T12:37:15","date_gmt":"2021-12-08T17:37:15","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/?p=69520"},"modified":"2021-12-08T12:37:15","modified_gmt":"2021-12-08T17:37:15","slug":"final-project-22","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/2021\/12\/08\/final-project-22\/","title":{"rendered":"Final Project"},"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=\"550\" data-height=\"300\" href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-content\/uploads\/2021\/12\/sketch-40.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=\"550\" height=\"300\"><\/iframe><pre class=\"language-javascript\"><code class=\"p5_editor language-javascript\">\/\/thien le, section d, project\n\nvar pressValue = 255;\nvar circValOne = 255;\nvar circValTwo = 255;\nvar circValThree = 255;\nvar cityImg;\nvar iceImg;\nvar forestImg;\nvar smoke = [];\nvar x;\nvar y;\nvar dx;\n\nfunction preload() {\n  cityImg = loadImage (\"https:\/\/i.imgur.com\/hmWYq6y.png\")\n  iceImg = loadImage (\"https:\/\/i.imgur.com\/bcdmnoM.png12\")\n  forestImg = loadImage (\"https:\/\/i.imgur.com\/SiHq9rT.png\")\n}\n\n\nfunction setup() {\n  createCanvas(550, 300);\n  background(\"#edc399\");\n  \/\/smoke\n  for (var i = 0; i &lt; 80; i ++) {\n        var startLocX = random(0, 270);\n        var startLocY = random(0, 300);\n        smoke[i] = makesmoke(startLocX, startLocY);\n    }\n\n\/\/clouds\n  x = int(random(0, 270));\n  y = int(random(250, 300));\n  \/\/random colors\n  \/\/velocity of cloud\n  dx = int(2);\n  dy = int(5);\n}\n\nfunction draw() {\n  screenText();\n  threeButtons();\n  cloud(x, y, dx);\n    x += dx;\n    \/\/once cloud hits the right, it switches side\n    if (dx &gt;= 0 & x > 250){\n        dx = -dx\n    }\n    else if (dx < 0 && x - 10 < 0){\n        dx = -dx\n    }\n  \n}\n  \n\nfunction screenText() {\n  push();\n  fill(255);\n  textSize(8);\n  text('P R E S S  1 ,  2 ,  O R  3  O N  K E Y B O A R D  T O  S T A R T !', 300, 30)\n  pop();\n}\n\nfunction aOrB() {\n  push();\n  fill(255);\n  textSize(10);\n  text(\"A\", 355, 255)\n  text(\"B\", 470, 255)\n  pop();\n\n}\nfunction choiceText() {\n  push();\n  fill(255);\n  textSize(8);\n  text('P R E S S  A  O R  B  T O  C H O O S E', 350, 270);\n  pop();\n}\n\nfunction badChoice() {\n  push();\n  fill(\"red\");\n  textSize(15);\n  textStyle(BOLD);\n  text('CONTINUE PRESSING B', 340, 260);\n  pop();\n}\nfunction threeButtons() { \/\/buttons that will display 3 facts about climate change\n    noStroke();\n    fill(circValOne);\n    circle(350, 70, 50, 50);\n    fill(circValTwo);\n    circle(420, 70, 50, 50);\n    fill(circValThree);\n    circle(490, 70, 50, 50);\n}\n\nfunction keyTyped() {\n  \/\/city\n  if (key === '1') {\n    circValOne = (\"#cc7161\");\n    circValTwo = 255;\n    circValThree = 255;\n    fill(255);\n    image(cityImg, 0, 0, 270, height);\n    cityButton();\n    cityFact();\n    choiceText();\n    aOrB();\n    \/\/ice\n  } \n  if (key === 'a') {\n    background(\"#014421\");\n    push();\n    textSize(15);\n    textAlign(CENTER);\n    fill(255);\n    text('YAY YOU SAVED THE EARTH!', 150, 150)\n    pop();\n  }\n  if (key === 'b') {\n     smokeDisplay();\n     badChoice();\n  }\n  if (key === '2') {\n    circValTwo = (\"#cc7161\");\n    circValOne = 255;\n    circValThree = 255;\n    image(iceImg, 0, 0, 270, height);\n    iceButton();\n    iceFact();\n    choiceText();\n    \/\/forest\n  } \n  else if (key === '3') {\n    circValThree = (\"#cc7161\");\n    circValTwo = 255;\n    circValOne = 255;\n    image(forestImg, 0, 0, 270, height);\n    forestButton();\n    forestFact();\n    choiceText();\n  }\n}\n\nfunction cityButton(){\n  push();\n  rectMode(CENTER);\n  fill(\"#638a7e\");\n  rect(360, 200, 100, 80, 20);\n  rect(480, 200, 100, 80, 20);\n  pop();\n  push();\n  textAlign(CENTER);\n  fill(255);\n  text('Walk, bike, or take public transportation', 310, 180, 100, 80);\n  text('Drive personal vehicle', 430, 185, 100, 80);\n  pop();\n}\n\nfunction iceButton(){\n  push();\n  rectMode(CENTER);\n  fill(\"#638a7e\");\n  rect(360, 200, 100, 80, 20);\n  rect(480, 200, 100, 80, 20);\n  pop();\n  push();\n  textAlign(CENTER);\n  fill(255);\n  text('Utilize smart power in homes', 310, 185, 100, 80);\n  text('Leave lights on everywhere', 430, 185, 100, 80);\n  pop();\n}\n\nfunction forestButton(){\n  push();\n  rectMode(CENTER);\n  fill(\"#638a7e\");\n  rect(360, 200, 100, 80, 20);\n  rect(480, 200, 100, 80, 20);\n  pop();\n  push();\n  textAlign(CENTER);\n  fill(255);\n  text('Encourage politicians to fund parks', 310, 180, 100, 80);\n  text('Use lots of paper', 430, 190, 100, 80);\n  pop();\n}\n\nfunction cityFact() {\n  push();\n  rectMode(CENTER);\n  fill(\"#edc399\");\n  rect(420, 130, 230, 60);\n  pop();\n  push();\n  textAlign(CENTER);\n  fill(255);\n  \/\/climate fact\n  fill(255);\n  text('Each year 1.2 trillion gallons of untreated sewage, stormwater, and industrial waste are dumped into US water', 310, 107, 230, 100);\n  pop();\n}\n\nfunction iceFact() {\n  \/\/climate fact\n  push();\n  rectMode(CENTER);\n  fill(\"#edc399\");\n  rect(420, 130, 230, 60);\n  pop();\n  push();\n  textAlign(CENTER);\n  fill(255);\n  \/\/climate fact\n  fill(255);\n  text('95% of the oldest and thickest ice in the Arctic is already gone', 310, 115, 230, 100);\n  pop();\n}\n\nfunction forestFact() {\n  \/\/climate fact\n  push();\n  rectMode(CENTER);\n  fill(\"#edc399\");\n  rect(420, 130, 230, 60);\n  pop();\n  push();\n  textAlign(CENTER);\n  fill(255);\n  \/\/climate fact\n  fill(255);\n  text('Deforestation emits more greenhouse gas emissions than 85 million cars would over their entire lifetime', 310, 107, 230, 100);\n  pop();\n}\n\n\/\/smoke object\nfunction drawsmoke() {\n    noStroke();\n    \/\/fill(255);\n    push();\n    translate(this.x, this.y);\n    fill(200, 200);\n    ellipse(1, 10, this.starH, this.starH);\n    pop();\n}\n\nfunction makesmoke(startLocX, startLocY) {\n    var smoke = {x: startLocX, \n               y: startLocY, \n               starH: random(10, 30),\n               speed: -1, \n               move: smokeMove, \n               draw: drawsmoke}\n    return smoke;\n}\n\nfunction smokeMove() { \/\/update position of smoke\n    this.x += this.speed\n    if (this.x &lt;= 0) {\n        this.x += 50\n    }\n}\n\nfunction smokeDisplay() { \n     for(i = 0; i &lt; smoke.length; i ++) {\n        smoke[i].move();\n        smoke[i].draw();\n    }\n}\n\n\/\/cloud\nfunction cloud(x, y, dx) {\n    fill(200, 200);\n    ellipse(x - 30, y + 20, 20, 20)\n    ellipse(x - 15, y + 10, 30, 40)\n    ellipse(x + 5, y + 5, 20, 30)\n    ellipse(x, y, 20, 10)\n}<\/code><\/pre><\/p><\/body><\/html>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":653,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/69520"}],"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\/653"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/comments?post=69520"}],"version-history":[{"count":1,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/69520\/revisions"}],"predecessor-version":[{"id":69522,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/69520\/revisions\/69522"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/media?parent=69520"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/categories?post=69520"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/tags?post=69520"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}