{"id":119,"date":"2017-09-26T20:01:55","date_gmt":"2017-09-26T20:01:55","guid":{"rendered":"https:\/\/www.thecoderschool.com\/blog\/newtons-gravity-as-coded-by-an-11yo-student\/"},"modified":"2022-10-13T20:50:18","modified_gmt":"2022-10-13T20:50:18","slug":"newtons-gravity-as-coded-by-an-11yo-student","status":"publish","type":"post","link":"https:\/\/www.thecoderschool.com\/blog\/newtons-gravity-as-coded-by-an-11yo-student\/","title":{"rendered":"Newton&#8217;s Gravity as Coded by an 11yo Student"},"content":{"rendered":"<p>Sometimes what the students do at our school amazes me, but one app has always stuck out in my mind. \u00a0We have a 13yo student who I&#8217;ll call LN, who&#8217;s been with us since we opened. \u00a0When he was 11, he created this incredible app he calls Gravity Crash. \u00a0LN is a big fan of physics, and it happened that his Code Coach was too &#8211; and so some pretty amazing coding ensued.<\/p>\n<p>LN&#8217;s game looks and plays like a standard billiards game (which in itself is already quite hard to code in Python). \u00a0But instead of hitting the cue ball, you create what he called &#8220;gravitational anomalies&#8221; (I guess he was a Start Trek TNG fan too!) that sucks the cue ball towards it (and orbits it, if placed correctly), using newtonian physics formulas. \u00a0What?!<\/p>\n<p>Take a look here, and be sure to widen the game screen so you can see the entire billiard table. \u00a0You can also open <a href=\"https:\/\/trinket.io\/python\/8c9fb646b0\" target=\"_blank\" rel=\"noopener\">Gravity Crash<\/a>\u00a0in a new window.<\/p>\n<p><center><iframe loading=\"lazy\" src=\"https:\/\/trinket.io\/embed\/python\/2e94445d1a\" width=\"100%\" height=\"356\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/center><\/p>\n<figure style=\"width: 396px\" class=\"wp-caption alignright\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.thecoderschool.com\/wp-content\/uploads\/2017\/09\/LawofGravity.png?format=original\" alt=\" Newton's Law of Universal Gravitation \" width=\"396\" height=\"286\" \/><figcaption class=\"wp-caption-text\">Newton&#8217;s Law of Universal Gravitation<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<p>So I want to point out that, even as a coder of 20 years, some of this would be mind-boggling for myself to write. \u00a0If you&#8217;re not a coder, just scroll through the code and you&#8217;ll be blown away. \u00a0If you&#8217;re a coder, check out how he handles collisions starting on line 171 (yep, granted, he needed some help on the vector and collision math!). \u00a0And if you&#8217;re a physicist, check out line 234, my favorite. \u00a0Break down the component parts, and [gasp!!], you have Newton&#8217;s Law of Universal Gravitation. \u00a0Let me sum that up for you, an 11 yo coded a pretty complex game in Python, and then decided to use Newtonian formulas to simulate gravity. \u00a0 Niiiiiiice.<\/p>\n<p>Now mind you, in our model, we have a Code Coach, directly mentoring our students &#8211; so building the app wasn&#8217;t completely unaided. \u00a0Moving the balls, collisions, even just setting up the triangle, requires some really good math knowledge.\u00a0 \u00a0But LN, again, an 11yo, understands how most of the code works, and coded a large part of it. \u00a0Think about how much coding AND math experience he gained coding this app. \u00a0Mind. \u00a0Blown.<\/p>\n<p><center><iframe loading=\"lazy\" class=\"giphy-embed\" src=\"https:\/\/giphy.com\/embed\/l0MYEqEzwMWFCg8rm\" width=\"480\" height=\"270\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/center><a href=\"https:\/\/giphy.com\/gifs\/chris-guardians-pratt-l0MYEqEzwMWFCg8rm\">via GIPHY<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Wanna be blown away by what kids can do when they&#8217;re paired with the right Code Coach? &nbsp;Take a look at Gravity Crash, a game coded by an 11yo at the time. &nbsp;A billiards game with real collisions and ball movement &#8211; and Newtonian physics. &nbsp;Need I say more?<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-119","post","type-post","status-publish","format-standard","hentry","category-coder-blog","entry"],"_links":{"self":[{"href":"https:\/\/www.thecoderschool.com\/blog\/wp-json\/wp\/v2\/posts\/119","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.thecoderschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.thecoderschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.thecoderschool.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.thecoderschool.com\/blog\/wp-json\/wp\/v2\/comments?post=119"}],"version-history":[{"count":1,"href":"https:\/\/www.thecoderschool.com\/blog\/wp-json\/wp\/v2\/posts\/119\/revisions"}],"predecessor-version":[{"id":12325,"href":"https:\/\/www.thecoderschool.com\/blog\/wp-json\/wp\/v2\/posts\/119\/revisions\/12325"}],"wp:attachment":[{"href":"https:\/\/www.thecoderschool.com\/blog\/wp-json\/wp\/v2\/media?parent=119"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.thecoderschool.com\/blog\/wp-json\/wp\/v2\/categories?post=119"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.thecoderschool.com\/blog\/wp-json\/wp\/v2\/tags?post=119"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}