{"id":69251,"date":"2021-12-03T15:07:22","date_gmt":"2021-12-03T20:07:22","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/?p=69251"},"modified":"2021-12-03T15:07:22","modified_gmt":"2021-12-03T20:07:22","slug":"final-project-2","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/2021\/12\/03\/final-project-2\/","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>In this game you try to keep the penguin alive. If the penguin touches the water you lose. the penguin has to jump between ice cubes floating across the screen. the ice cubes are objects stored in an array. the penguin can jump when it is touching the ice cube. two challenges appear while playing. one makes the ice cubes smaller, and one makes the ice cubes move faster. if you navigate through these challenges you can get to safety and win the game. I attached a video of me completing the game because it might not be a game you can complete first try.<\/p>\n\n\n\n<p>I wanted to create a fun game that had a relation to climate change. since climate change is melting ice which might cause harm to wildlife, I made this game where the ice is melting. If I had more time I might add more challenges and make the movement of the ice cubes look more realistic, like they are actually in water.<\/p>\n\n\n\n<div><a class=\"p5_sketch_link\" data-width=\"600\" data-height=\"600\" data-fontsize=\"8\" href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-content\/uploads\/2021\/12\/sketch-7.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=\"600\"><\/iframe><pre class=\"language-javascript\" style=\"font-size:8px !important; line-height:11.6px !important\"><code class=\"p5_editor language-javascript\" style=\"font-size:8px !important;\">var ice = []\nvar penguinY = 0; \nvar penguinX = 300;    \nvar penguinDy = 0; \nvar count = 0\nvar menu = 0\n\nfunction setup() {\n  createCanvas(600,600)\n\n  \/\/creating the 4 icecubes\n  for (i = 0; i &lt; 4; i++) {\n    iceX = random(width)\n    iceY = 440\n    size = 70\n    ice[i] = makeIce(iceX, iceY, size)\n  }\n}\n\nfunction draw() {\n\n  \/\/menu page\n  if (menu &lt; 1) {\n    fill(\"lightgreen\")\n    rect(0,0,800,600)\n    textAlign(CENTER)\n    textFont('Helvetica')\n    textSize(18)\n    fill(\"black\")\n    text(\"The ice is melting!\", 400,220)\n    text(\"get to safety!\", 400,370)\n    fill(\"red\")\n    text(\"use the arrow keys to move left and right\", 400,280)\n    text(\"spacebar to jump\", 400,310)\n    text(\"press spacebar to begin\", 400, 450)\n    \n    }\n\n    \/\/win page\n  else if (count &gt;= 3200){\n      fill(220)\n      noStroke()\n      background(\"lightblue\")\n      ellipse(400,650,1200,400)\n      textSize(18)\n      fill(0)\n      text(\"you made it to safety!\",400,300)\n      translate(400,420)\n      drawPenguin(0,0)\n      noLoop()\n    }\n  \n  else {\n  \n  \/\/scenary\n  background(\"lightblue\")\n  fill(\"blue\")\n  rect(0, height - 100, width, 100)\n  \/\/sun that rotates\n  push()\n  translate(100,100)\n  rotate(radians(count))\n  drawSun()\n  pop()\n  \n  stroke(0)\n\n  \/\/checking if penguin is on any icecube or above the icecubes\n  if (penguinY &lt;= 440 &\n    (penguinX >= ice[0].fx && penguinX <= ice[0].fx+75) ||\n    (penguinX >= ice[1].fx && penguinX <= ice[1].fx+75) ||\n    (penguinX >= ice[2].fx && penguinX <= ice[2].fx+75) ||\n    (penguinX >= ice[3].fx && penguinX <= ice[3].fx+75)\n    ) { \n    penguinY = min(395, penguinY + penguinDy);\n     \n    \/\/checking if penguin is below the icecubes\n  } else { \n    \n    penguinY = min(height, penguinY + penguinDy);\n  }\n \n  \/\/showing the penguin and ice\n  drawPenguin(penguinX,penguinY)\n  showIce()\n\n  \/\/penguin gravity\n  penguinDy = penguinDy + .25;\n\n  \/\/penguin left\/right movement\n  if (keyIsDown(LEFT_ARROW)){\n    penguinX-=5\n  }\n  if (keyIsDown(RIGHT_ARROW)){\n    penguinX+=5\n  }\n\n  \/\/ if you touch the water \"you lose\"\n  if (penguinY &gt;= 550) {\n    textSize(18)\n    text(\"You Lose\",400,300)\n    fill(255)\n    drawDeadPenguin(penguinX,penguinY)\n    noLoop()\n  }\n  \/\/use this count to initate challenges levels\n  count+=1\n\n  \/\/challenge level 1\n  countdown(900)\n\n  if (count &gt;= 1100 & count <= 1500){\n    ice[0].icesize = 30\n    ice[1].icesize = 30\n    ice[2].icesize = 30\n    ice[3].icesize = 30\n  }\n\n  if (count >= 1500 && count <= 2000){\n    ice[0].icesize = 70\n    ice[1].icesize = 70\n    ice[2].icesize = 70\n    ice[3].icesize = 70\n  }\n\n  \/\/challenge level 2\n  countdown(1800)\n\n  if (count >= 2000 && count <= 2400){\n    ice[0].icespeed = -4\n    ice[1].icespeed = -5\n    ice[2].icespeed = -6\n    ice[3].icespeed = -7\n  }\n\n  if (count >= 2400 && count <= 2401){\n    ice[0].icespeed = random(-1.5,-3)\n    ice[1].icespeed = random(-1.5,-3)\n    ice[2].icespeed = random(-1.5,-3)\n    ice[3].icespeed = random(-1.5,-3)\n  }\n  \n  \/\/approaching the end text\n  if (count >= 2600 && count <= 2800){\n    textSize(22)\n    text(\"you are approaching the end\",400,300)\n}\n}\n}\n\n\n\n\/\/penguin jump\nfunction keyPressed() {\n  \n  if (keyCode === 32) {\n    if (penguinY >= 360 && (\n      (penguinX >= ice[0].fx && penguinX <= ice[0].fx+75) ||\n      (penguinX >= ice[1].fx && penguinX <= ice[1].fx+75) ||\n      (penguinX >= ice[2].fx && penguinX <= ice[2].fx+75) ||\n      (penguinX >= ice[3].fx && penguinX <= ice[3].fx+75)\n      )) { \n    penguinDy = -10;\n      }   \n      menu = 1\n      \n      \n  }\n  \n}\n\n\/\/two functions for alive penguin and dead penguin\nfunction drawPenguin(x,y){\n  fill(0);\n  noStroke();\n  ellipse(x, y+2, 46, 81);\n  fill(255);\n  ellipse(x, y+10, 31, 56);\n  ellipse(x-5, y-20, 21, 21);\n  ellipse(x+5, y-20, 21, 21);\n  fill(255,150,40);\n  triangle(x-7, y-15, x+7, y-15, x,y-3);\n  ellipse(x+8, y+42, 15, 8);\n  ellipse(x-8, y+42, 15, 8);\n  fill(0);\n  ellipse(x-8, y-21, 8, 8);\n  ellipse(x+8, y-21, 8, 8);\n  ellipse(x-21, y+10, 12, 40);\n  ellipse(x+21, y+10, 12, 40);\n  \n}\n\nfunction drawDeadPenguin(x,y){\n  fill(0);\n  noStroke();\n  ellipse(x, y+2, 46, 81);\n  fill(255);\n  ellipse(x, y+10, 31, 56);\n  ellipse(x-5, y-20, 21, 21);\n  ellipse(x+5, y-20, 21, 21);\n  fill(255,150,40);\n  triangle(x-7, y-15, x+7, y-15, x,y-3);\n  ellipse(x+8, y+42, 15, 8);\n  ellipse(x-8, y+42, 15, 8);\n  fill(0);\n  textSize(12)\n  text(\"x\",x-9, y-20);\n  text(\"x\",x+6, y-20);\n  ellipse(x-21, y+10, 12, 40);\n  ellipse(x+21, y+10, 12, 40);\n  \n\n}\n\/\/ function creates the sun\nfunction drawSun(){\n  fill(\"gold\")\n  stroke(\"gold\")\n  line(0,0,60,60)\n  line(0,0,-60,60)\n  line(0,0,-60,-60)\n  line(0,0,60,-60)\n  line(0,0,35,80)\n  line(0,0,-35,80)\n  line(0,0,35,-80)\n  line(0,0,-35,-80)\n  line(0,0,80,0)\n  line(0,0,-80,0)\n  line(0,0,0,80)\n  line(0,0,0,-80)\n  line(0,0,75,35)\n  line(0,0,-75,-35)\n  line(0,0,75,-35)\n  line(0,0,-75,35)\n  circle(0,0,100)\n}\n\n\/\/function for the countdown for a challenge\nfunction countdown(x){\nif (count &gt;= x & count <= x+200 ){\n  textSize(30)\n  text(\"Challenge in\",350,200)\n}\nif (count >= x+16 && count <x+70 ){\n  textSize(50)\n  text(\"3\",350,300)\n}\nif (count >= x+70 && count <=x+140 ){\n  textSize(50)\n  text(\"2\",350,300)\n}\nif (count >= x+140 && count <=x+200 ){\n  textSize(50)\n  text(\"1\",350,300)\n}\n}\n\n\/\/functions for the creation\/movement of the ice\nfunction makeIce(iceX, iceY, size) {\n  var ice = {\n      fx: iceX,\n      fy: iceY,\n      icesize: size,\n      icespeed: random(-1.5, -3),\n      icemove: moveIce,\n      icecolor: color(random(50, 100), random(100, 200), 255),\n      icedraw: drawIce\n  }\n  return ice\n}\nfunction moveIce() {\n  this.fx += this.icespeed\n  if (this.fx <= -10) {\n      this.fx += width\n  }\n}\nfunction drawIce() {\n  stroke(0)\n  fill(this.icecolor);\n  rect(this.fx, this.fy, this.icesize, 70)\n}\nfunction showIce() {\n  for (i = 0; i &lt; ice.length; i++) {\n      ice[i].icemove()\n      ice[i].icedraw()\n  }\n}\n\n<\/code><\/pre><\/div><\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>In this game you try to keep the penguin alive. If the penguin touches the water you lose. the penguin has to jump between ice cubes floating across the screen. the ice cubes are objects stored in an array. the penguin can jump when it is touching the ice cube. two challenges appear while playing. &hellip; <a href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/2021\/12\/03\/final-project-2\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Final Project&#8221;<\/span><\/a><\/p>\n","protected":false},"author":659,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[116,55,1],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/69251"}],"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\/659"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/comments?post=69251"}],"version-history":[{"count":10,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/69251\/revisions"}],"predecessor-version":[{"id":69266,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/69251\/revisions\/69266"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/media?parent=69251"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/categories?post=69251"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/tags?post=69251"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}