{"id":1116,"date":"2021-11-07T18:24:14","date_gmt":"2021-11-07T23:24:14","guid":{"rendered":"https:\/\/openlab.bmcc.cuny.edu\/mmp-270-fall-2021\/?p=1116"},"modified":"2021-11-08T16:43:44","modified_gmt":"2021-11-08T21:43:44","slug":"player-physics-leighton-snyder","status":"publish","type":"post","link":"https:\/\/openlab.bmcc.cuny.edu\/mmp-270-fall-2021\/2021\/11\/07\/player-physics-leighton-snyder\/","title":{"rendered":"Player Physics &#8211; Leighton Snyder"},"content":{"rendered":"\n<p>I finished the player physics lab, and while it&#8217;s still rough around the edges, I think it&#8217;s a good place to stop for now. There are a lot of things to keep track of code-wise, but I think I was able to get a hold of it eventually.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>I was able to add a double-jump (although there&#8217;s likely a better way) and here&#8217;s how I went about it:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"634\" height=\"332\" src=\"https:\/\/openlab.bmcc.cuny.edu\/mmp-270-fall-2021\/wp-content\/uploads\/sites\/1770\/2021\/11\/InkedScreenshot-2021-11-07-174822_LI.jpg\" alt=\"\" class=\"wp-image-1118\" srcset=\"https:\/\/openlab.bmcc.cuny.edu\/mmp-270-fall-2021\/wp-content\/uploads\/sites\/1770\/2021\/11\/InkedScreenshot-2021-11-07-174822_LI.jpg 634w, https:\/\/openlab.bmcc.cuny.edu\/mmp-270-fall-2021\/wp-content\/uploads\/sites\/1770\/2021\/11\/InkedScreenshot-2021-11-07-174822_LI-300x157.jpg 300w\" sizes=\"auto, (max-width: 634px) 100vw, 634px\" \/><figcaption>I added two new variables: jump_max for the maximum number of jumps you can take  (which I exported so you can edit it quickly) and jump_count for keeping track of how many jumps the character has left.<\/figcaption><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"955\" src=\"https:\/\/openlab.bmcc.cuny.edu\/mmp-270-fall-2021\/wp-content\/uploads\/sites\/1770\/2021\/11\/InkedScreenshot-2021-11-07-175344_LI-1024x955.jpg\" alt=\"\" class=\"wp-image-1120\" srcset=\"https:\/\/openlab.bmcc.cuny.edu\/mmp-270-fall-2021\/wp-content\/uploads\/sites\/1770\/2021\/11\/InkedScreenshot-2021-11-07-175344_LI-1024x955.jpg 1024w, https:\/\/openlab.bmcc.cuny.edu\/mmp-270-fall-2021\/wp-content\/uploads\/sites\/1770\/2021\/11\/InkedScreenshot-2021-11-07-175344_LI-300x280.jpg 300w, https:\/\/openlab.bmcc.cuny.edu\/mmp-270-fall-2021\/wp-content\/uploads\/sites\/1770\/2021\/11\/InkedScreenshot-2021-11-07-175344_LI-768x717.jpg 768w, https:\/\/openlab.bmcc.cuny.edu\/mmp-270-fall-2021\/wp-content\/uploads\/sites\/1770\/2021\/11\/InkedScreenshot-2021-11-07-175344_LI.jpg 1044w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>Jump Max in the Player properties.<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"924\" height=\"782\" src=\"https:\/\/openlab.bmcc.cuny.edu\/mmp-270-fall-2021\/wp-content\/uploads\/sites\/1770\/2021\/11\/InkedScreenshot-2021-11-07-175303_LI.jpg\" alt=\"\" class=\"wp-image-1119\" srcset=\"https:\/\/openlab.bmcc.cuny.edu\/mmp-270-fall-2021\/wp-content\/uploads\/sites\/1770\/2021\/11\/InkedScreenshot-2021-11-07-175303_LI.jpg 924w, https:\/\/openlab.bmcc.cuny.edu\/mmp-270-fall-2021\/wp-content\/uploads\/sites\/1770\/2021\/11\/InkedScreenshot-2021-11-07-175303_LI-300x254.jpg 300w, https:\/\/openlab.bmcc.cuny.edu\/mmp-270-fall-2021\/wp-content\/uploads\/sites\/1770\/2021\/11\/InkedScreenshot-2021-11-07-175303_LI-768x650.jpg 768w\" sizes=\"auto, (max-width: 924px) 100vw, 924px\" \/><figcaption>I added &#8220;jump_count &gt; 0&#8221; as a condition for can_jump.<br>The jump_count resets every time you touch the ground.<br>And 1 is subtracted from jump_count everytime you jump.<\/figcaption><\/figure>\n\n\n\n<p>So, here is everything together. I also added the arm to the player (doesn&#8217;t follow the mouse yet) and changed how gravity and jump height is calculated so I could get more consistent jumps.<\/p>\n\n\n\n<figure class=\"wp-block-video\"><video controls preload=\"auto\" src=\"https:\/\/openlab.bmcc.cuny.edu\/mmp-270-fall-2021\/wp-content\/uploads\/sites\/1770\/2021\/11\/Standard-DEBUG-2021-11-07-17-45-13.mp4\"><\/video><figcaption>I swear there is sound; it just wasn&#8217;t recorded. I&#8217;ll fix that one of these days.<\/figcaption><\/figure>\n\n\n\n<p>Thanks!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I finished the player physics lab, and while it&#8217;s still rough around the edges, I think it&#8217;s a good place to stop for now. There are a lot of things to keep track of code-wise, but I think I was able to get a hold of it eventually. I was able to add a double-jump&hellip; <a class=\"more-link\" href=\"https:\/\/openlab.bmcc.cuny.edu\/mmp-270-fall-2021\/2021\/11\/07\/player-physics-leighton-snyder\/\">Continue reading <span class=\"screen-reader-text\">Player Physics &#8211; Leighton Snyder<\/span><\/a><\/p>\n","protected":false},"author":4194,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"portfolio_post_id":0,"portfolio_citation":"","portfolio_annotation":"","openlab_post_visibility":"","footnotes":""},"categories":[43,56],"tags":[],"coauthors":[23],"class_list":["post-1116","post","type-post","status-publish","format-standard","hentry","category-developer","category-player-physics","entry"],"_links":{"self":[{"href":"https:\/\/openlab.bmcc.cuny.edu\/mmp-270-fall-2021\/wp-json\/wp\/v2\/posts\/1116","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/openlab.bmcc.cuny.edu\/mmp-270-fall-2021\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/openlab.bmcc.cuny.edu\/mmp-270-fall-2021\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/openlab.bmcc.cuny.edu\/mmp-270-fall-2021\/wp-json\/wp\/v2\/users\/4194"}],"replies":[{"embeddable":true,"href":"https:\/\/openlab.bmcc.cuny.edu\/mmp-270-fall-2021\/wp-json\/wp\/v2\/comments?post=1116"}],"version-history":[{"count":3,"href":"https:\/\/openlab.bmcc.cuny.edu\/mmp-270-fall-2021\/wp-json\/wp\/v2\/posts\/1116\/revisions"}],"predecessor-version":[{"id":1123,"href":"https:\/\/openlab.bmcc.cuny.edu\/mmp-270-fall-2021\/wp-json\/wp\/v2\/posts\/1116\/revisions\/1123"}],"wp:attachment":[{"href":"https:\/\/openlab.bmcc.cuny.edu\/mmp-270-fall-2021\/wp-json\/wp\/v2\/media?parent=1116"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/openlab.bmcc.cuny.edu\/mmp-270-fall-2021\/wp-json\/wp\/v2\/categories?post=1116"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/openlab.bmcc.cuny.edu\/mmp-270-fall-2021\/wp-json\/wp\/v2\/tags?post=1116"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/openlab.bmcc.cuny.edu\/mmp-270-fall-2021\/wp-json\/wp\/v2\/coauthors?post=1116"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}