{"id":69296,"date":"2021-12-03T23:03:53","date_gmt":"2021-12-04T04:03:53","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/?p=69296"},"modified":"2021-12-03T23:03:53","modified_gmt":"2021-12-04T04:03:53","slug":"69296","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/2021\/12\/03\/69296\/","title":{"rendered":""},"content":{"rendered":"<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD HTML 4.0 Transitional\/\/EN\" \"http:\/\/www.w3.org\/TR\/REC-html40\/loose.dtd\">\n<html><body><div class=\"wp-block-file\"><a class=\"p5_sketch_link\" data-width=\"500\" data-height=\"500\" href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-content\/uploads\/2021\/12\/sketch-12.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=\"500\" height=\"500\"><\/iframe><pre class=\"language-javascript\"><code class=\"p5_editor language-javascript\">\/\/Amalia Kutin\n\/\/15-104 B\nvar bergSize;\nvar polar;\nvar pieces = [];\nvar afterNoon;\nvar skyColor;\nvar clouds = [];\nvar skyOrb;\nvar skyOrbColor;\n\n\nfunction setup() {\n    createCanvas(500, 500);\n    background(158, 198, 255);\n    bergSize = 400;\n    skyColor = 125;\n    skyOrb = 0;\n    skyOrbColor = false;\n    noStroke();\n    polar = {x: 250, y: 350, dx: 0};\n    for(let i = 0; i &lt; 10; i++) clouds[i] = {x: random()*500, y: random()*180};\n}\n\nfunction draw() {\n    background(158, 198, 255);\n    fill(61, 120, 204);\n    rect(0, 200, 500, 300);\n    fill(143, 185, 191);\n    beginShape();\n    vertex(250-(bergSize\/2), 350);\n    vertex(250-(bergSize\/4), 350-(bergSize\/4));\n    vertex(250+(bergSize\/4), 350-(bergSize\/4));\n    vertex(250+(bergSize\/2), 350);\n    vertex(250+(bergSize\/4), 350+(bergSize\/4));\n    vertex(250-(bergSize\/4), 350+(bergSize\/4));\n    endShape(CLOSE);\n    for(let i = 0; i &lt; pieces.length; i++) drawIce(pieces[i]);\n    drawSky();\n    for(let i = 0; i &lt; clouds.length; i++) drawClouds(clouds[i]);\n    drawBear(polar);\n}\n\nfunction drawBear(b) {\n    fill(255);\n    beginShape();\n    vertex(b.x-20, b.y-20);\n    vertex(b.x+10, b.y-30);\n    vertex(b.x+20, b.y-25);\n    vertex(b.x+15, b.y-10);\n    vertex(b.x+20, b.y+10);\n    vertex(b.x+10, b.y+10);\n    vertex(b.x, b.y);\n    vertex(b.x-10, b.y+5);\n    vertex(b.x-10, b.y+10);\n    vertex(b.x-20, b.y+10);\n    vertex(b.x-30, b.y+5);\n    vertex(b.x-35, b.y-5);\n    endShape(CLOSE);\n    fill(156, 96, 114);\n    circle(b.x+20, b.y-25, 5);\n    fill(0);\n    circle(b.x+10, b.y-22, 5);\n    circle(b.x+13, b.y-27, 5);\n    b.x += random()*6 - 3;\n    b.y += random()*6 - 3;\n    if(b.x &lt; 260-bergSize\/2) b.x += 10;\n    if(b.x &gt; 240+bergSize\/2) b.x -= 10;\n    if(b.y &lt; 360-bergSize\/4) b.y += 10;\n    if(b.y &gt; 340+bergSize\/4) b.y -= 10;\n}\n\nfunction drawIce(i) {\n    fill(143, 185, 191);\n    beginShape();\n    vertex(i.x-(i.s\/2), i.y);\n    vertex(i.x-(i.s\/4), i.y-(i.s\/4));\n    vertex(i.x+(i.s\/4), i.y-(i.s\/4));\n    vertex(i.x+(i.s\/2), i.y);\n    vertex(i.x+(i.s\/4), i.y+(i.s\/4));\n    vertex(i.x-(i.s\/4), i.y+(i.s\/4));\n    endShape(CLOSE);\n    if(i.c % 8 &lt; 2) i.x++;\n    else if(i.c % 8 &lt; 4) i.y++;\n    else if(i.c % 8 &lt; 6) i.x--;\n    else i.y--;\n    i.c++;\n}\n\nfunction drawSky() {\n    if(afterNoon) skyColor-=0.25;\n    else skyColor+=0.25;\n    fill(skyColor, skyColor, 120+skyColor\/2);\n    rect(0, 0, 500, 200);\n    if(skyColor == 200) afterNoon = true;\n    if(skyColor == 50) afterNoon = false;\n    if (skyOrbColor) fill(219, 252, 255);\n    else fill(235, 196, 68);\n    circle(skyOrb, 100, 60);\n    skyOrb+=(0.25*500\/150);\n    if (skyOrb &gt; 500) {\n        skyOrb = 0;\n        if (skyOrbColor) skyOrbColor = false;\n        else skyOrbColor = true;\n    }\n}\n\nfunction drawClouds(c) {\n    fill(255);\n    ellipse(c.x%500, c.y, 50, 30);\n    c.x++;\n}\n\nfunction mousePressed() {\n    if(bergSize &gt; 150) bergSize -= 10;\n    var newPiece;\n    for(let i = 0; i &lt; 20; i++) newPiece = {x: random()*500, y: 200+random()*300, s: random()*60, c: 0};\n    pieces[pieces.length] = newPiece;\n}\n<\/code><\/pre><\/div>\n\n\n\n<p>My project revolved around a polar bear and melting ice. There is an iceberg that the user melts by clicking, and a polar bear stuck on it. Small pieces of ice are generated as the main piece melts. The sky has clouds that move across the sky. There is also a sun\/moon that moves across the sky as well. The polar also randomly moves around, but it&rsquo;s constrained by the size of the iceberg. This project demonstrates the small scale effects of climate change.<\/p>\n\n\n\n<p>If I had more time, I would have considered adding a second polar bear. The issue is that it would need to stay on the iceberg while also not bumping into its friend.<\/p><\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>My project revolved around a polar bear and melting ice. There is an iceberg that the user melts by clicking, and a polar bear stuck on it. Small pieces of ice are generated as the main piece melts. The sky has clouds that move across the sky. There is also a sun\/moon that moves across &hellip; <a href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/2021\/12\/03\/69296\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;&#8221;<\/span><\/a><\/p>\n","protected":false},"author":652,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[116,56],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/69296"}],"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\/652"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/comments?post=69296"}],"version-history":[{"count":2,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/69296\/revisions"}],"predecessor-version":[{"id":69299,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/69296\/revisions\/69299"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/media?parent=69296"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/categories?post=69296"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/tags?post=69296"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}