{"id":6555,"date":"2020-06-03T21:36:57","date_gmt":"2020-06-04T02:36:57","guid":{"rendered":"https:\/\/www.rushworth.us\/lisa\/?p=6555"},"modified":"2020-06-29T10:08:06","modified_gmt":"2020-06-29T15:08:06","slug":"scratch","status":"publish","type":"post","link":"https:\/\/www.rushworth.us\/lisa\/?p=6555","title":{"rendered":"Scratch"},"content":{"rendered":"<p>A few of the books I got for Anya are introductions to programming &#8212; Python, C++, and this GUI block-based system called Scratch. She likes using Python because Scott and I use it, but she absolutely adores <a href=\"https:\/\/scratch.mit.edu\/\" target=\"_blank\" rel=\"noopener noreferrer\">Scratch. <\/a>She has <a href=\"https:\/\/www.amazon.com\/Beginners-Guide-Coding-Marc-Scott\/dp\/1681195402\" target=\"_blank\" rel=\"noopener noreferrer\">A Beginner&#8217;s Guide To Coding<\/a> (Marc Scott) that I picked up from <a href=\"http:\/\/bookoutlet.com\/Loyalty\/Referral?raf=vgXHXqE&amp;c=url\" target=\"_blank\" rel=\"noopener noreferrer\">Book Outlet (I get a bonus 10$ when someone uses my referral link)<\/a> for a couple of bucks. We&#8217;ve got a <a href=\"https:\/\/scratch.mit.edu\/studios\/26831562\/\" target=\"_blank\" rel=\"noopener noreferrer\">studio of our games online<\/a>, and she&#8217;s excited to share the games with family members.<\/p>\n<p>Tricks we&#8217;ve leaned so far:<\/p>\n<ul>\n<li>The UI will not match a book written a few years ago \ud83d\ude42 This reminded me a bit of the &#8220;Internet Directory&#8221; book I had in 1994 &#8230; an obviously silly concept today, but a completely reasonable thing in 1994 when a decent bit of the content was still modem numbers. A book about a UI &#8230; it&#8217;s a good base &#8212; providing great first projects. But it took Anya a little while to accept that, while the book quite clearly told her to click an icon that looked like this &#8230; in the intervening 18-24 months, the UI had changed. How did I know <em>this<\/em> is what you click now? I mean, other than the fact it goes into the thing that has the same function as the one your book describes? A good guess!<\/li>\n<li>You can create variables with the same name. I am certain they are assigned some underlying UID that you never see, but if you have two variables named &#8216;score&#8217; and the score doesn&#8217;t seem to be incrementing &#8230; look at your variable list.<\/li>\n<li>Variable scope of &#8220;this sprite&#8221; and &#8220;all sprites&#8221; is straight-forward until you create clones. &#8220;This sprite&#8221; means &#8220;this clone of a sprite&#8221;. We had a &#8220;all sprites&#8221; variable for speed and <em>all<\/em> of the clones will change speed each time a new clone pops in. This is cool if it&#8217;s what you want to do. I&#8217;ve also created variables scoped to &#8220;this sprite&#8221; to build clones that move at different speeds.<\/li>\n<li>You cannot, unfortunately, change a variable&#8217;s scope after you create it. You need to make a new one.<\/li>\n<li>The &#8220;glide&#8221; motion isn&#8217;t good for sensing collision. While the glide is in progress, that&#8217;s the block that is executing. Anya has a game where a <a href=\"https:\/\/scratch.mit.edu\/projects\/391055481\/\" target=\"_blank\" rel=\"noopener noreferrer\">crab collects crystals while avoiding divers<\/a> which uses the fact you <em>cannot<\/em> check if Thing1 is touching Thing2. The grab can move through gliding divers with impunity. If you want to detect collisions, use a loop where the X and Y coordinates are changed in small increments instead of glide. Technically, there&#8217;s no collision detection while my X coordinate is changing, but that&#8217;s such a brief time interval that you cannot effectively avoid bumping into the other sprite while it moves.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/www.rushworth.us\/lisa\/?attachment_id=6558\" rel=\"attachment wp-att-6558\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6558\" src=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2020\/06\/scratch-changeXYInsteadOfGlide.png\" alt=\"\" width=\"368\" height=\"395\" srcset=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2020\/06\/scratch-changeXYInsteadOfGlide.png 368w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2020\/06\/scratch-changeXYInsteadOfGlide-279x300.png 279w\" sizes=\"auto, (max-width: 368px) 100vw, 368px\" \/><\/a><\/p>\n<ul>\n<li>You can avoid the sprite being moved off of the screen to avoid collision by adding a bounce when the sprite is on the edge.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/www.rushworth.us\/lisa\/?attachment_id=6559\" rel=\"attachment wp-att-6559\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6559\" src=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2020\/06\/scratch-Bounce.png\" alt=\"\" width=\"175\" height=\"79\" \/><\/a><\/p>\n<ul>\n<li>You need to zero out your variables when the green flag is pressed, otherwise replaying the game by clicking the green flag again produces really strange behavior (you&#8217;ve already won or lost)<\/li>\n<li>Fractions can be used in places where they have integer examples. Specifically, you can pause for fractional seconds.<\/li>\n<li>When using clones, hide the &#8220;base&#8221; sprite that exists in the &#8216;when green flag clicked&#8217; instantiation; use a &#8216;show&#8217; in the &#8216;when I start as a clone&#8217; block. Otherwise you have one sprite sitting at the edge of the screen<\/li>\n<\/ul>\n<p><a href=\"https:\/\/www.rushworth.us\/lisa\/?attachment_id=6557\" rel=\"attachment wp-att-6557\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6557\" src=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2020\/06\/scratch-hideBaseShowClone.png\" alt=\"\" width=\"980\" height=\"395\" srcset=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2020\/06\/scratch-hideBaseShowClone.png 980w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2020\/06\/scratch-hideBaseShowClone-300x121.png 300w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2020\/06\/scratch-hideBaseShowClone-768x310.png 768w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2020\/06\/scratch-hideBaseShowClone-750x302.png 750w\" sizes=\"auto, (max-width: 980px) 100vw, 980px\" \/><\/a><\/p>\n<ul>\n<li>&#8220;My Blocks&#8221; is used to build functions. In Anya&#8217;s <a href=\"https:\/\/scratch.mit.edu\/projects\/400960433\" target=\"_blank\" rel=\"noopener noreferrer\">Simon Says&#8230;<\/a> game, we use the pseudorandom number generator to select &#8220;Simon&#8217;s&#8221; instructions and call a block based on the generated number.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/www.rushworth.us\/lisa\/?attachment_id=6560\" rel=\"attachment wp-att-6560\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-6560\" src=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2020\/06\/scratch-YourBlocks-1024x740.png\" alt=\"\" width=\"960\" height=\"694\" srcset=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2020\/06\/scratch-YourBlocks-1024x740.png 1024w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2020\/06\/scratch-YourBlocks-300x217.png 300w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2020\/06\/scratch-YourBlocks-768x555.png 768w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2020\/06\/scratch-YourBlocks-750x542.png 750w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2020\/06\/scratch-YourBlocks.png 1060w\" sizes=\"auto, (max-width: 960px) 100vw, 960px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A few of the books I got for Anya are introductions to programming &#8212; Python, C++, and this GUI block-based system called Scratch. She likes using Python because Scott and I use it, but she absolutely adores Scratch. She has A Beginner&#8217;s Guide To Coding (Marc Scott) that I picked up from Book Outlet (I &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[507,1040],"tags":[45,104,995,996],"class_list":["post-6555","post","type-post","status-publish","format-standard","hentry","category-parenting","category-scratch","tag-coding","tag-education","tag-newbie","tag-scratch"],"_links":{"self":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/6555","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6555"}],"version-history":[{"count":2,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/6555\/revisions"}],"predecessor-version":[{"id":6933,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/6555\/revisions\/6933"}],"wp:attachment":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6555"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6555"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6555"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}