Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 79 - 2617_JSSPS_C-4
P. 79

    CREATING A GAME IN SCRATCH

                     Let’s learn how to create a game in Scratch using Sensing blocks and Variables to make the
                     game more interactive and engaging.

                     To create a game in Scratch, follow the given steps:
                     Step 1:  Choose a sprite as the main character of your game (a cat or a player).

                     Step 2:  Add another sprite to be a target the player needs to touch (a star).
                     Step 3:   Create  a  Variable and name it  score  for the
                              player sprite.                                           when    clicked

                     Step 4:   Place  the  Star sprite at a random position on
                              the stage.                                               set  score    to  0
                     Step 5:  Choose a suitable backdrop for the game.                 forever

                     Step 6:   Now, create  the given script for your player             if    key  right arrow  pressed?  then
                              sprite.
                                                                                           change x by  10

                                                                                         if    key  left arrow  pressed?  then

                                                                                           change y by -10

                                                                                         if    key  up arrow  pressed?  then

                                                                                           change y by  10

                                                                                         if    key  down arrow  pressed?  then

                                                                                           change y by -10

                                                                                         if    touching  Star  ?  then

                                                                                           change score    by  1

                                                                                           go to x: -120  y: 110

                                                                                         if    score  = 10   then

                                                                                           say  You Win  for  2  seconds
                     Use the arrow keys on your keyboard to move the sprite                stop  all

                     up, down, left or right. Whenever the sprite touches the
                     Star, your score increases. If your score reaches 10, you
                     win the game!

                                                                         Designing Games and Storyboard in Scratch 3   77

| 74 75 76 77 78 79 80 81 82 83 84 |