Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 106 - logicode 2609 C5
P. 106

    This block shows the value of the chosen variable on the
                            show variable  my variable                                                                                                            Suppose you have to code a dance party in Scratch where characters keep
                                                        screen.                                                                                                   dancing in a loop until stopped, which block will you use for this and which

                                                                                                                                                                  songs would you play in the program?

                            hide variable  my variable  This block hides the chosen variable from the screen.

                                                                                                                                                           USING THE AI FEATURES OF SCRATCH

                                CREATING A GAME IN SCRATCH                                                                                      There      are     many       powerful

                                                                                     when    clicked                                            extensions  you  can  use  to  make
                      Have you ever dreamt of creating a computer game?                                                                         your  projects  more  dynamic

                      Here’s  your  chance to turn it  into  reality  with a         set  score   to  0                                         and interactive.  To use  them,
                      Scratch project. Let’s learn how to create a game in           forever                                                    you  must  first  add  them  to  the
                      Scratch using Sensing blocks and Variables to make               if   key  right arrow  pressed?                          blocks palette.
                      the game more interactive and engaging.                                                        then                       To add  these  extensions  to  the
                                                                                        change x by  10
                      To create a game in Scratch, follow the given steps:                                                                      blocks  palette,  follow  the given

                      Step  1    Choose a sprite as the main character of                                                                       steps:
                                                                                       if   key  left arrow  pressed?
                                your game (a cat or a player).                                                       then                       Step  1    Click    on     the     Add

                      Step  2    Add another sprite to be a target the player           change y by -10                                                    Extension         button.
                                needs to touch (a star).                                                                                        Step  2    Choose the desired extension.

                      Step  3    Create a Variable and name it score v for             if   key  up arrow   pressed?  then                      The chosen extension will be added to the blocks palette. Let’s learn about some of these
                                the player sprite.                                      change y by  10                                         exciting extensions.

                      Step  4    Place the Star sprite at a random position
                                on the stage.                                          if   key  down arrow  pressed?  then                     VIDEO SENSING

                      Step  5    Choose a suitable backdrop for the game.                                                                       The Video Sensing extension lets you use your webcam
                                                                                        change y by -10                                         to control your project. It can detect movement in front of
                      Step  6    Now, create the given script for your player                                                                   the camera and use it to make things happen in the game,
                                sprite.
                                                                                       if   touching  Star  ?  then                             like moving a sprite or triggering an action.

                                                                                                                                                The Video Sensing extension includes the following
                                                                                        change score    by  1
                                                                                                                                                blocks:
                                                                                        go to x: -120  y: 110

                                                                                                                                                                                          It starts a script when the camera detects motion
                                                                                       if    score  = 10   then                                                  when video motion  >  10  greater than a set value (like waving your hand).

                      Use the arrow keys on your keyboard to move the                    say  You Win  for  2  seconds
                      sprite  up, down, left or right. Whenever the sprite              stop  all                                                                                         This block  detects  the  motion  or direction  of
                      touches the Star, your score increases. If your score                                                                                video  motion  on  sprite      movement  captured  by  the webcam.  You  can
                      reaches 10, you win the game!                                                                                                                                       apply it to a specific sprite or the entire stage.

                      104   Premium Edition-V

| 101 102 103 104 105 106 107 108 109 110 111 |