{"id":621,"date":"2012-11-12T17:19:40","date_gmt":"2012-11-12T17:19:40","guid":{"rendered":"http:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/?p=621"},"modified":"2012-11-12T17:19:40","modified_gmt":"2012-11-12T17:19:40","slug":"nature-3","status":"publish","type":"post","link":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/2012\/11\/12\/nature-3\/","title":{"rendered":"Nature 3"},"content":{"rendered":"<p>This was my fall-back idea when I couldn&#8217;t think of anything to do for the last piece. I wanted to simply do a piece with clouds going by in the sky. However, I ran into the same problems we ran into with the moving gnats in that when the clouds hit an edge\/corner in certain ways they would get stuck on it, and since they would reset to x and y values of zero they would get stuck after one loop.<br \/>\nI wanted to add different shapes of clouds, but I wanted to figure out the edge issue first as it seemed more important to figure out.<br \/>\nSprite mySprite;<br \/>\nSprite[] sprites = new Sprite[30];<br \/>\nPImage myPicture;<br \/>\nPImage myPicture2;<br \/>\nvoid setup() {<br \/>\n  size(350, 350);<br \/>\n  background(200);<br \/>\n  myPicture = loadImage(&#8220;cloud.png&#8221;);<br \/>\n  myPicture2 = loadImage(&#8220;sky.png&#8221;);<br \/>\n  imageMode(CENTER);<\/p>\n<p>  for (int i=0;i<sprites.length;i++) { \n    sprites[i]=new Sprite();\n  }\n}\n\nvoid draw() {\n  background(myPicture2);\n  for (int z=0;z<sprites.length;z++) { \n    sprites[z].moveSprite();\n    sprites[z].drawSprite();\n  }\n}\n\nclass Sprite {\n  float x;\n  float y;\n  float imageSize;\n  float xmoveAmount;\n  float ymoveAmount;\n\n  Sprite() {\n \n    x = random(width); \n    y = random(height);\n    xmoveAmount = 1; \n    ymoveAmount = 2;\n    imageSize = 10 + random(30); \n  }\n\n  void drawSprite() {\n    image(myPicture, x, y, imageSize, imageSize);\n  }\n\n  void moveSprite() {\n    x+=xmoveAmount; \n    y+=ymoveAmount;\n\n    if (x>=(width-imageSize\/2)-1) {<br \/>\n      x=30;<br \/>\n    }<br \/>\n    else if (x<=imageSize\/2-1) {\n      x=30;\n    }\n    else if (y>=(height-imageSize\/2)-1) {<br \/>\n      y=30;<br \/>\n    }<br \/>\n    else if (y<=imageSize\/2-1) {\n      y=30;\n    }\n  }\n}\n\nI\u2019m unable to get my projects to load properly on the blog currently, so I\u2019m just going to post the code for the time being, and will probably upload a screen shot later or something to show what it should look like when working.\n<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This was my fall-back idea when I couldn&#8217;t think of anything to do for the last piece. I wanted to simply do a piece with clouds going by in the sky. However, I ran into the same problems we ran &hellip; <a href=\"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/2012\/11\/12\/nature-3\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":8,"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\/621"}],"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\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/comments?post=621"}],"version-history":[{"count":1,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/posts\/621\/revisions"}],"predecessor-version":[{"id":622,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/posts\/621\/revisions\/622"}],"wp:attachment":[{"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/media?parent=621"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/categories?post=621"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/tags?post=621"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}