{"id":1469,"date":"2021-09-21T10:06:03","date_gmt":"2021-09-21T17:06:03","guid":{"rendered":"https:\/\/lbmslab.org\/lab\/?page_id=1469"},"modified":"2021-09-23T21:06:22","modified_gmt":"2021-09-24T04:06:22","slug":"mouse-maze-part-1","status":"publish","type":"page","link":"https:\/\/lbmslab.org\/lab\/mouse-maze-part-1\/","title":{"rendered":"Mouse Maze (Part 1)"},"content":{"rendered":"\n<p>We&#8217;re going to use scratch to make a game. A mouse will have to find his way through a maze to get his cheese without touching the walls.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Setting Up the Project<\/h2>\n\n\n\n<p>The first thing we need to do is give our project a name. Find where it says &#8220;Untitled&#8221; at the top of the screen (it might have a number as well) and change the title to &#8220;Mouse Maze&#8221;.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-9.17.59-AM.png\"><img loading=\"lazy\" decoding=\"async\" width=\"279\" height=\"70\" src=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-9.17.59-AM.png\" alt=\"\" class=\"wp-image-1470\"\/><\/a><\/figure>\n\n\n\n<p>Now we need to get rid of the cat sprite. Find the sprite in the library and click the trash can to remove it.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-9.16.15-AM.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"263\" height=\"221\" src=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-9.16.15-AM.jpg\" alt=\"\" class=\"wp-image-1472\"\/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Get the Mouse<\/h2>\n\n\n\n<p>Now we&#8217;ll get the mouse. Hover over the cat icon in the sprite library (bottom right) and select &#8220;Choose a Sprite.&#8221;<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-9.16.46-AM.png\"><img loading=\"lazy\" decoding=\"async\" width=\"235\" height=\"263\" src=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-9.16.46-AM.png\" alt=\"\" class=\"wp-image-1473\"\/><\/a><\/figure>\n\n\n\n<p>Scroll until you see Mouse1 and select that sprite.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-9.17.35-AM.png\"><img loading=\"lazy\" decoding=\"async\" width=\"179\" height=\"177\" src=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-9.17.35-AM.png\" alt=\"\" class=\"wp-image-1474\"\/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Make Him Move<\/h2>\n\n\n\n<p>From &#8220;Events&#8221;, add the &#8220;When flag clicked&#8221; event to the sprite.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-9.18.54-AM.png\"><img loading=\"lazy\" decoding=\"async\" width=\"335\" height=\"213\" src=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-9.18.54-AM.png\" alt=\"\" class=\"wp-image-1476\" srcset=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-9.18.54-AM.png 335w, https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-9.18.54-AM-300x191.png 300w\" sizes=\"auto, (max-width: 335px) 100vw, 335px\" \/><\/a><\/figure>\n\n\n\n<p>We want to constantly check if the user is pressing any buttons. Add a &#8220;forever&#8221; loop from the controls and snap it to the when flag clicked block<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-9.19.39-AM.png\"><img loading=\"lazy\" decoding=\"async\" width=\"245\" height=\"136\" src=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-9.19.39-AM.png\" alt=\"\" class=\"wp-image-1478\"\/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-9.19.48-AM.png\"><img loading=\"lazy\" decoding=\"async\" width=\"189\" height=\"238\" src=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-9.19.48-AM.png\" alt=\"\" class=\"wp-image-1479\"\/><\/a><\/figure>\n\n\n\n<p>Our mouse needs to move in four directions: right, left, up, and down. We need to add a check for each one of those. It doesn&#8217;t matter which order we check, but we&#8217;ll start with going right.<\/p>\n\n\n\n<p>In &#8220;controls&#8221;, find a block called &#8220;If &#8230; then&#8221; and drag it into the work area. It looks like this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-9.20.08-AM.png\"><img loading=\"lazy\" decoding=\"async\" width=\"196\" height=\"165\" src=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-9.20.08-AM.png\" alt=\"\" class=\"wp-image-1482\"\/><\/a><\/figure>\n\n\n\n<p>In &#8220;sensing&#8221; find a diamond shape that says &#8220;key &lt;space&gt; pressed?&#8221;  <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-9.20.21-AM.png\"><img loading=\"lazy\" decoding=\"async\" width=\"283\" height=\"136\" src=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-9.20.21-AM.png\" alt=\"\" class=\"wp-image-1483\"\/><\/a><\/figure>\n\n\n\n<p>Drag that into the hexagonal space in the &#8220;if &#8230; then&#8221; block. the block will change shape so everything fits.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-9.20.30-AM.png\"><img loading=\"lazy\" decoding=\"async\" width=\"359\" height=\"153\" src=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-9.20.30-AM.png\" alt=\"\" class=\"wp-image-1486\" srcset=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-9.20.30-AM.png 359w, https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-9.20.30-AM-300x128.png 300w\" sizes=\"auto, (max-width: 359px) 100vw, 359px\" \/><\/a><\/figure>\n\n\n\n<p>This block is checking if the player is pressing the space bar- but we want to check for the arrow key. Click the word &#8220;space&#8221; and a list of keys will pop up. Choose &#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\/2021\/09\/Screen-Shot-2021-09-21-at-9.20.38-AM.png\"><img loading=\"lazy\" decoding=\"async\" width=\"329\" height=\"438\" src=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-9.20.38-AM.png\" alt=\"\" class=\"wp-image-1487\" srcset=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-9.20.38-AM.png 329w, https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-9.20.38-AM-225x300.png 225w\" sizes=\"auto, (max-width: 329px) 100vw, 329px\" \/><\/a><\/figure>\n\n\n\n<p>Now we need to tell the program what we want to happen when the right arrow gets pressed. We want two things to happen: We want the mouse to point to the right, and we want him to move in that direction. Here are the two commands to add (they are under &#8220;motion&#8221;):<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-9.21.13-AM-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"324\" height=\"169\" src=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-9.21.13-AM-1.png\" alt=\"\" class=\"wp-image-1489\" srcset=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-9.21.13-AM-1.png 324w, https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-9.21.13-AM-1-300x156.png 300w\" sizes=\"auto, (max-width: 324px) 100vw, 324px\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-9.21.22-AM.png\"><img loading=\"lazy\" decoding=\"async\" width=\"372\" height=\"300\" src=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-9.21.22-AM.png\" alt=\"\" class=\"wp-image-1490\" srcset=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-9.21.22-AM.png 372w, https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-9.21.22-AM-300x242.png 300w\" sizes=\"auto, (max-width: 372px) 100vw, 372px\" \/><\/a><\/figure>\n\n\n\n<p>Drag the entire &#8220;if then&#8221; block inside the &#8220;forever&#8221; loop.<\/p>\n\n\n\n<p>Now when you click the flag above the stage (upper right), you can press the right arrow to move the mouse to the right!<\/p>\n\n\n\n<p>Now do the same thing for the left, up, and down arrows. Make sure to change the number in  the &#8220;point in direction&#8221; block to match the way the mouse should point. You can use the direction guide to help you.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-9.21.56-AM.png\"><img loading=\"lazy\" decoding=\"async\" width=\"384\" height=\"488\" src=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-9.21.56-AM.png\" alt=\"\" class=\"wp-image-1492\" srcset=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-9.21.56-AM.png 384w, https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-9.21.56-AM-236x300.png 236w\" sizes=\"auto, (max-width: 384px) 100vw, 384px\" \/><\/a><\/figure>\n\n\n\n<p>When you are done your code should look like this:<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-9.23.09-AM.png\"><img loading=\"lazy\" decoding=\"async\" width=\"364\" height=\"625\" src=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-9.23.09-AM.png\" alt=\"\" class=\"wp-image-1494\" srcset=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-9.23.09-AM.png 364w, https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-9.23.09-AM-175x300.png 175w\" sizes=\"auto, (max-width: 364px) 100vw, 364px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Be careful!<\/h2>\n\n\n\n<p>Look at each of the &#8220;if&#8230; then&#8221; blocks. Notice that they are stacked on top of each other. They are not inside each other! Make sure to avoid something like this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-10.01.48-AM.png\"><img loading=\"lazy\" decoding=\"async\" width=\"344\" height=\"607\" src=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-10.01.48-AM.png\" alt=\"\" class=\"wp-image-1495\" srcset=\"https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-10.01.48-AM.png 344w, https:\/\/lbmslab.org\/lab\/wp-content\/uploads\/2021\/09\/Screen-Shot-2021-09-21-at-10.01.48-AM-170x300.png 170w\" sizes=\"auto, (max-width: 344px) 100vw, 344px\" \/><\/a><\/figure>\n\n\n\n<p><a href=\"https:\/\/lbmslab.org\/lab\/mouse-maze-ii\/\" data-type=\"page\" data-id=\"1499\">Part 2: Making the Maze<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>We&#8217;re going to use scratch to make a game. A mouse will have to find his way through a maze to get his cheese without touching the walls. Setting Up the Project The first thing we need to do is give our project a name. Find where it says &#8220;Untitled&#8221; at the top of the [&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-1469","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/lbmslab.org\/lab\/wp-json\/wp\/v2\/pages\/1469","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=1469"}],"version-history":[{"count":10,"href":"https:\/\/lbmslab.org\/lab\/wp-json\/wp\/v2\/pages\/1469\/revisions"}],"predecessor-version":[{"id":1519,"href":"https:\/\/lbmslab.org\/lab\/wp-json\/wp\/v2\/pages\/1469\/revisions\/1519"}],"wp:attachment":[{"href":"https:\/\/lbmslab.org\/lab\/wp-json\/wp\/v2\/media?parent=1469"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}