{"id":593,"date":"2012-11-12T16:50:14","date_gmt":"2012-11-12T16:50:14","guid":{"rendered":"http:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/?p=593"},"modified":"2012-11-12T16:50:14","modified_gmt":"2012-11-12T16:50:14","slug":"jayson-corey-project-1-flies","status":"publish","type":"post","link":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/2012\/11\/12\/jayson-corey-project-1-flies\/","title":{"rendered":"Jayson Corey Project 1: Flies"},"content":{"rendered":"<p>This project was inspired by everyone&#8217;s favorite pest that isn&#8217;t called a mosquito: Flies! Also the book Lord of the Flies, somehow, I guess. Anyway, the program generates flies of random sizes that use noise to fly around the screen in natural ways. There is no interactive element in this project, except the interaction between your eyeballs and the program while it is running. Enjoy!<\/p>\n<p><script type=\"application\/processing\">\r\nSprite mySprite;\r\nSprite[] sprites = new Sprite [50];\r\n\r\nvoid setup () {\r\n  size (200, 200);\r\n  background (255);\r\n  smooth ();\r\n  stroke (0);\r\n  fill (125);\r\n\r\n  for (int i = 0; i < sprites.length; i++) {\r\n    sprites[i] = new Sprite (); } }\r\n\r\nvoid draw () {\r\n  background (255);\r\n  for (int z = 0; z < sprites.length; z++) {\r\n    sprites[z].moveSprite();\r\n    sprites[z].drawSprite(); } }\r\n\r\nclass Sprite {\r\n  float x = 100;\r\n  float y = 100;\r\n  float bodysize = 4;\r\n  float xMove = 1;\r\n  float yMove = -1;\r\n  float xtime = 0.0;  \r\n  float ytime = 100.0;\r\n  float increment = 0.01;\r\n  \r\n  Sprite () {\r\n    x = random (width);\r\n    y = random (width);\r\n    xMove = 5 - random (10);\r\n    yMove = 5 - random (10);\r\n    bodysize = 4 + random(8);\r\n    xtime = random(width);\r\n    ytime = random(height); }\r\n    \r\n void drawSprite () { ellipse (x, y, bodysize, bodysize); }\r\n    \r\n void moveSprite () {\r\n   x = noise (xtime) * width;  \r\n   y = noise (ytime) * height; \r\n   xtime += increment;  \r\n   ytime += increment; \r\n  \r\n  if (x >= (width - bodysize \/2)) {\r\n    xMove = 0 - xMove; }\r\n    \r\n  else if (x <= bodysize \/ 2) {\r\n    xMove = 0 - xMove; }\r\n    \r\n  else if (y >= (height - bodysize \/ 2)) {\r\n    yMove = 0 - yMove; }\r\n    \r\n  else if (y <= bodysize \/ 2) {\r\n    yMove = 0 - yMove; } } }\r\n<\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This project was inspired by everyone&#8217;s favorite pest that isn&#8217;t called a mosquito: Flies! Also the book Lord of the Flies, somehow, I guess. Anyway, the program generates flies of random sizes that use noise to fly around the screen &hellip; <a href=\"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/2012\/11\/12\/jayson-corey-project-1-flies\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":15,"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\/593"}],"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\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/comments?post=593"}],"version-history":[{"count":1,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/posts\/593\/revisions"}],"predecessor-version":[{"id":594,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/posts\/593\/revisions\/594"}],"wp:attachment":[{"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/media?parent=593"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/categories?post=593"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/tags?post=593"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}