{"id":412,"date":"2012-11-11T05:55:33","date_gmt":"2012-11-11T05:55:33","guid":{"rendered":"http:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/?p=412"},"modified":"2012-11-11T05:55:33","modified_gmt":"2012-11-11T05:55:33","slug":"project-1-hurricane","status":"publish","type":"post","link":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/2012\/11\/11\/project-1-hurricane\/","title":{"rendered":"Project 1 &#8211; Hurricane"},"content":{"rendered":"<p>The final sketch of the three part series of this project features inspiration from the most recent storm, hurricane Sandy. However, the difference is in this sketch is I&#8217;ve created a mini game which allows the user to try and thwart the hurricane as it reaches the coastline. The players must control the hurricane with the four arrow keys, and direct the storm into the targets displayed on screen. If the hurricane hits all of the targets before reaching the end of the shoreline, the storm will perform a shrinking animation signalling the player has won, and restart the game. If the player misses the targets, the game will restart. In order to build suspense, the size of the hurricane grows as each target is collected until finally it reaches critical mass where the player either wins or loses. You can play the game below!<\/p>\n<p><script type=\"application\/processing\">\r\nPImage backgroundImage;\r\nPImage hurricane;\r\nfloat hurricaneWidth;\r\nfloat hurricaneHeight;\r\nint rotation;\r\nint xOff = 900;\r\nint yOff = 125;\r\nint stepSizeX = 3;\r\nint stepSizeY = 5;\r\nint phase = 8;\r\nboolean shrink = false;\r\nint currYTarg=0;\r\nint yVal = (int)random(100, 60);\r\nboolean hit = true;\r\nint shrinkCounter = 0;\r\n\r\n\r\nvoid setup() {\r\n  size(1000, 600); \r\n  hurricaneWidth = 150;\r\n  hurricaneHeight = 150;\r\n  backgroundImage = loadImage(\"http:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-content\/uploads\/2012\/11\/backgroundImage.png\"); \r\n  hurricane = loadImage(\"http:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-content\/uploads\/2012\/11\/hurricane.png\");\r\n  rotation = 0;\r\n}\r\n\r\nvoid draw() {\r\n  imageMode(CORNER);\r\n  image(backgroundImage, 0, 0, 1000, 600); \r\n  image(hurricane, xOff, yOff, hurricaneWidth + ((width-xOff)\/4), hurricaneWidth + ((width-xOff)\/4));\r\n  if (shrink == false) {\r\n    xOff -=1;\r\n  }\r\n  runGame();\r\n  if (shrink == true) {\r\n    shrinkCounter+=1;\r\n    hurricaneWidth -=1;\r\n  }\r\n  if (shrinkCounter == 350) {\r\n    shrink = false;\r\n    resetGame();\r\n  }\r\n}\r\n\r\nvoid keyPressed() {\r\n  \/\/print(\"xAWAY: \" +abs((xOff+(hurricaneWidth\/2) - ((phase * 100)))) +\" \"+ \"yAWAY: \" + abs((yOff + (hurricaneWidth\/2))-currYTarg)+ \" \");\r\n  if (keyCode == UP) {\r\n    yOff -= stepSizeY;\r\n  }\r\n  if (keyCode == DOWN) {\r\n    yOff += stepSizeY;\r\n  }  \r\n\r\n  if (keyCode == LEFT) {\r\n    xOff -= stepSizeX;\r\n  }  \r\n\r\n  if (keyCode == RIGHT) {\r\n    xOff += stepSizeX;\r\n  }\r\n}\r\n\r\nvoid createAirCycles(int phase) {\r\n  strokeWeight(5);\r\n  fill(255, 0, 0);\r\n  ellipse(phase*100, yVal, 30, 30);\r\n  strokeWeight(20);\r\n  ellipse(phase*100, yVal, 65, 65);\r\n  currYTarg = yVal;\r\n}\r\n\r\nvoid runGame() {\r\n  if (phase!=1) {\r\n    checkForCollision();\r\n    if (hit == true) {\r\n      phase--;\r\n      hit = false;\r\n      yVal = (int)random(100, 600);\r\n    }\r\n    createAirCycles(phase);\r\n  }\r\n\r\n  if (phase == 1) {\r\n    shrink = true;\r\n  }\r\n  else if ( xOff < 0 && shrink == false) {\r\n    for (int i = 0; i < 1000000; i ++) {\r\n      \r\n    }\r\n    resetGame();\r\n  }\r\n}\r\n\r\nvoid checkForCollision() {\r\n  if (50 > abs((xOff+(hurricaneWidth\/2) - ((phase * 100)))) && 50+(90- (phase*10)) > abs((yOff + (hurricaneWidth\/2))-currYTarg)) {\r\n    hit=true;\r\n  }\r\n}\r\n\r\nvoid resetGame() {\r\n  phase = 9; \r\n  xOff = 900;\r\n  yOff = 125;\r\n  shrinkCounter = 0;\r\n  hurricaneWidth = 150;\r\n}\r\n\r\n<\/script> <\/p>\n","protected":false},"excerpt":{"rendered":"<p>The final sketch of the three part series of this project features inspiration from the most recent storm, hurricane Sandy. However, the difference is in this sketch is I&#8217;ve created a mini game which allows the user to try and &hellip; <a href=\"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/2012\/11\/11\/project-1-hurricane\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/posts\/412"}],"collection":[{"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/comments?post=412"}],"version-history":[{"count":2,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/posts\/412\/revisions"}],"predecessor-version":[{"id":414,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/posts\/412\/revisions\/414"}],"wp:attachment":[{"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/media?parent=412"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/categories?post=412"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/tags?post=412"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}