Page 144 - Chinmaya_C7_flipbook
P. 144

Let us take a look at some of the blocks from Block toolbar:

                        Scene  : It is used to modify the background of the game simulator. Some of the commonly
                  used blocks of this section are:
                     Screen width: It stores the value of the width of the screen.
                     Background image: It stores an image for the background.
                     Set Background Color: It is used to set the background colour.
                     Set Background Image: It is used to set an image as background.

                      Loops  : It is used to repeat a set of block multiple times.

                  Repeat: It is used to repeat the execution of a set of block multiple times.
                      Logic  : It is used to add conditional blocks to the program.

                  If-else: It is used to make decisions based on a condition. If the condition is true, then the if block
                  is executed otherwise else block will be executed.

                       Variables  : It is used to create variables.
                       Math  : It contains blocks to perform mathematical operations.


                  BUILDING A MUSIC PLAYER

                  Step  1   Open Makecode , click on 'New Project'. Write the name of project 'building a music
                            player', and click on 'Create'.
                  Step  2   Click on 'Loops', and select 'repeat' block, drag it to the workspace and drop the 'repeat'

                            block to 'on start' block.











                  Step  3   Change the value of '4' to '10' in the 'repeat' block.

                  Step  4   In 'Music', select 'Play sound until done', it will appear on the workspace, and then drag
                            and drop the 'Play sound until done', block in the 'repeat' block.













                  Step  5   When you click on the 'Start the simulator' button, you will hear the music 10 times. The
                            loop repeats itself 10 times. The flow starts with 1 and with each iteration, it increments

                            the value by 1. Each time loop completes once iteration, and you will hear music once.




                  142   Premium Edition-VII                                                                                                                                                              Techipedia (Microsoft MakeCode Arcade)  PB
   139   140   141   142   143   144   145   146   147   148   149