Page 64 - 2501_KVS_C-5
P. 64

Aryan: Variables? What are these variables, dear? It’s a new word for me.

                       Gowri: Yes, sure dear! I know, it’s a new word for you. I will explain now its meaning to you.
                       Variable means varying and varying means changing. So a variable is a name, which stores some
                       value and its value can be changed at any time.

                       Aryan: Please tell me more about it also with the help of examples.


                       Gowri: Yes, sure, dear! We can learn this topic by the following blocks.

                  6.2   CREATE VARIABLES  AND  CHANGING THEIR  VALUES—

                         “VARIABLES” BLOCK

                  6.2.1 “Make a variable’’ button
                  This is a button in Variables block used to create a variable with a  name given by
                  us. Once a variable is created, it can be used by either a single sprite or all sprites,

                  depending on how it is set up. When we click on “Make a variable” button, then a
                  window appears as shown in Fig. 6.6 (having more details to learn it). E.g. create two
                  variables named “score” and “life”. “score” variable is used to count, number of times

                  “missiles” hits the planet and destroys it. “life” variable is used to count, number of
                  times planets hit the “spaceship” and decreases its life, which is decided as 5 as per
                  the game criteria.







                                                                         Creates a new
                                                                      variable, which only
                                             Enter here New           this sprite can see.
                                              Variable name,
                                             for creating it.




                                            Creates a new variable,
                                           which all sprites can see.


                                                                  Fig. 6.6


                                    Gowri: We can also store any value in this variable.



                                    Aryan: How can we give values to this variable and also change its
                                    value?


                                    Gowri: Yes, dear! Let’s learn it now.

                62                         KVS DELHI REGION 2025
   59   60   61   62   63   64   65   66   67   68   69