{"id":1606,"date":"2022-02-08T11:18:07","date_gmt":"2022-02-08T18:18:07","guid":{"rendered":"https:\/\/lbmslab.org\/lab\/?page_id=1606"},"modified":"2022-02-08T11:38:45","modified_gmt":"2022-02-08T18:38:45","slug":"scratch-project-move","status":"publish","type":"page","link":"https:\/\/lbmslab.org\/lab\/scratch-project-move\/","title":{"rendered":"Scratch project- move!"},"content":{"rendered":"\n<p>We&#8217;re going to program a sprite to move using the arrow keys!<\/p>\n\n\n\n<p>Instructions<\/p>\n\n\n\n<p>Open Scratch (<a rel=\"noreferrer noopener\" href=\"https:\/\/scratch.mit.edu\" target=\"_blank\">https:\/\/scratch.mit.edu<\/a>).<\/p>\n\n\n\n<p>If you have an account, sign in. If you don&#8217;t have an account, you should create one so your work is automatically saved.<\/p>\n\n\n\n<p>Select &#8220;Create&#8221; at the top of the page.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-9.33.00-AM.png\"><img loading=\"lazy\" decoding=\"async\" width=\"812\" height=\"92\" src=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-9.33.00-AM.png\" alt=\"\" class=\"wp-image-1608\" srcset=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-9.33.00-AM.png 812w, https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-9.33.00-AM-300x34.png 300w, https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-9.33.00-AM-768x87.png 768w\" sizes=\"auto, (max-width: 812px) 100vw, 812px\" \/><\/a><\/figure>\n\n\n\n<p>The Scratch editing window will open. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-9.41.00-AM-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"643\" src=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-9.41.00-AM-1-1024x643.png\" alt=\"\" class=\"wp-image-1610\" srcset=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-9.41.00-AM-1-1024x643.png 1024w, https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-9.41.00-AM-1-300x188.png 300w, https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-9.41.00-AM-1-768x482.png 768w, https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-9.41.00-AM-1-1536x964.png 1536w, https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-9.41.00-AM-1-2048x1286.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>Scratch always starts new projects with one sprite, the cat. We&#8217;re going to write some code that will let us use the arrow keys to move. <\/p>\n\n\n\n<p>Here&#8217;s what our code will do: When we start it, it will constantly check if we are pressing any of the arrow keys. If we are pressing an arrow key, the code will either move the cat forward, move it backward, or turn it left or right.<\/p>\n\n\n\n<p>On the left side of the screen, select the yellow circle labelled &#8220;Events.&#8221; The Events blocks will appear.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-9.48.52-AM.png\"><img loading=\"lazy\" decoding=\"async\" width=\"599\" height=\"1024\" src=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-9.48.52-AM-599x1024.png\" alt=\"\" class=\"wp-image-1611\" srcset=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-9.48.52-AM-599x1024.png 599w, https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-9.48.52-AM-175x300.png 175w, https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-9.48.52-AM.png 614w\" sizes=\"auto, (max-width: 599px) 100vw, 599px\" \/><\/a><\/figure>\n\n\n\n<p>Drag this block into the code space:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-9.50.02-AM-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"240\" height=\"122\" src=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-9.50.02-AM-1.png\" alt=\"\" class=\"wp-image-1613\"\/><\/a><\/figure>\n\n\n\n<p>Notice that the block is round on the top and has a notch on the bottom. Whenever a code block has a notch, we can attach another block.<\/p>\n\n\n\n<p>Select the orange  circle labelled &#8220;Control&#8221;. The control blocks will appear.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-9.52.54-AM.png\"><img loading=\"lazy\" decoding=\"async\" width=\"580\" height=\"940\" src=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-9.52.54-AM.png\" alt=\"\" class=\"wp-image-1614\" srcset=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-9.52.54-AM.png 580w, https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-9.52.54-AM-185x300.png 185w\" sizes=\"auto, (max-width: 580px) 100vw, 580px\" \/><\/a><\/figure>\n\n\n\n<p>Find the block that says &#8220;Forever&#8221; and drag it to connect to with the flag block in the code window.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-9.55.33-AM-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"996\" height=\"552\" src=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-9.55.33-AM-1.png\" alt=\"\" class=\"wp-image-1617\" srcset=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-9.55.33-AM-1.png 996w, https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-9.55.33-AM-1-300x166.png 300w, https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-9.55.33-AM-1-768x426.png 768w\" sizes=\"auto, (max-width: 996px) 100vw, 996px\" \/><\/a><\/figure>\n\n\n\n<p>Notice that the forever block doesn&#8217;t have a notch at the bottom. This block will loop through all of the code until with stop the program.<\/p>\n\n\n\n<p>Now that you have a loop, let&#8217;s put in some controls. There are a lot of blocks to add, but they all tell you exactly what they are doing.<\/p>\n\n\n\n<p>Our first set of blocks will check if we are pressing the right arrow. If we are pressing the right arrow, then the cat will move forward.<\/p>\n\n\n\n<p>Find the &#8220;if&#8221; block and put it inside the forever block. The forever block will get bigger so the  other block will fit.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-10.01.28-AM.png\"><img loading=\"lazy\" decoding=\"async\" width=\"932\" height=\"712\" src=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-10.01.28-AM.png\" alt=\"\" class=\"wp-image-1620\" srcset=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-10.01.28-AM.png 932w, https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-10.01.28-AM-300x229.png 300w, https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-10.01.28-AM-768x587.png 768w\" sizes=\"auto, (max-width: 932px) 100vw, 932px\" \/><\/a><\/figure>\n\n\n\n<p>Now we need to sense if the right arrow key is being pressed. Go to the sensing blocks (the cyan\/light blue circle) and add the shape that says &#8220;key space pressed?&#8221; to the &#8220;if&#8221; block.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-10.05.29-AM.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"565\" src=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-10.05.29-AM-1024x565.png\" alt=\"\" class=\"wp-image-1621\" srcset=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-10.05.29-AM-1024x565.png 1024w, https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-10.05.29-AM-300x166.png 300w, https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-10.05.29-AM-768x424.png 768w, https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-10.05.29-AM.png 1200w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>Click where the block says &#8220;space&#8221; and change it to &#8220;right arrow&#8221;.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-10.07.32-AM.png\"><img loading=\"lazy\" decoding=\"async\" width=\"546\" height=\"944\" src=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-10.07.32-AM.png\" alt=\"\" class=\"wp-image-1622\" srcset=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-10.07.32-AM.png 546w, https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-10.07.32-AM-174x300.png 174w\" sizes=\"auto, (max-width: 546px) 100vw, 546px\" \/><\/a><\/figure>\n\n\n\n<p>Now, whatever commands inside the &#8220;if&#8221; block will be be followed when you press the right arrow.<\/p>\n\n\n\n<p>Switch to the &#8220;motion&#8221; blocks. Drag the block that says &#8220;move 10 steps&#8221; into the if statement.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-10.10.04-AM-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"424\" src=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-10.10.04-AM-1-1024x424.png\" alt=\"\" class=\"wp-image-1624\" srcset=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-10.10.04-AM-1-1024x424.png 1024w, https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-10.10.04-AM-1-300x124.png 300w, https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-10.10.04-AM-1-768x318.png 768w, https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-10.10.04-AM-1.png 1240w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>You have written your first program! Press the green flag above the stage to run it. Now when you press the right arrow, the cat will move forward!<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-10.11.57-AM.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1010\" height=\"832\" src=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-10.11.57-AM.png\" alt=\"\" class=\"wp-image-1625\" srcset=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-10.11.57-AM.png 1010w, https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-10.11.57-AM-300x247.png 300w, https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-10.11.57-AM-768x633.png 768w\" sizes=\"auto, (max-width: 1010px) 100vw, 1010px\" \/><\/a><\/figure>\n\n\n\n<p>To make the cat move backward, add another if statement, but have it check the left arrow and change the move to negative steps. I also changed the steps to 5 and -5 to make the cat move slower. Make sure you put it UNDER the first &#8220;if&#8221; block, not inside it!<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-10.36.25-AM.png\"><img loading=\"lazy\" decoding=\"async\" width=\"666\" height=\"606\" src=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-10.36.25-AM.png\" alt=\"\" class=\"wp-image-1633\" srcset=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-10.36.25-AM.png 666w, https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-10.36.25-AM-300x273.png 300w\" sizes=\"auto, (max-width: 666px) 100vw, 666px\" \/><\/a><\/figure>\n\n\n\n<p>Now our cat moves forward and backward. The next step: add turns!<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-10.35.26-AM.png\"><img loading=\"lazy\" decoding=\"async\" width=\"612\" height=\"968\" src=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-10.35.26-AM.png\" alt=\"\" class=\"wp-image-1632\" srcset=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-10.35.26-AM.png 612w, https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2022\/02\/Screen-Shot-2022-02-08-at-10.35.26-AM-190x300.png 190w\" sizes=\"auto, (max-width: 612px) 100vw, 612px\" \/><\/a><\/figure>\n\n\n\n<p>That&#8217;s it!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We&#8217;re going to program a sprite to move using the arrow keys! Instructions Open Scratch (https:\/\/scratch.mit.edu). If you have an account, sign in. If you don&#8217;t have an account, you should create one so your work is automatically saved. Select &#8220;Create&#8221; at the top of the page. The Scratch editing window will open. Scratch always [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":"","_links_to":"","_links_to_target":""},"class_list":["post-1606","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/lbmslab.org\/lab\/wp-json\/wp\/v2\/pages\/1606","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lbmslab.org\/lab\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/lbmslab.org\/lab\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/lbmslab.org\/lab\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lbmslab.org\/lab\/wp-json\/wp\/v2\/comments?post=1606"}],"version-history":[{"count":7,"href":"https:\/\/lbmslab.org\/lab\/wp-json\/wp\/v2\/pages\/1606\/revisions"}],"predecessor-version":[{"id":1635,"href":"https:\/\/lbmslab.org\/lab\/wp-json\/wp\/v2\/pages\/1606\/revisions\/1635"}],"wp:attachment":[{"href":"https:\/\/lbmslab.org\/lab\/wp-json\/wp\/v2\/media?parent=1606"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}