Resetting the Movement Counter

Resetting the Movement Counter

If you click the stack of blocks a few times, you will notice that the number of movements keeps increasing. For example, if you have clicked the stack of blocks three times, the number of movements variable will be 24 (8 times 3).

We now want to reset the movement counter at the beginning of our program.

Setting the value of a variable at the beginning of a program is called initialisation, which is good Coding practice.

Another common example of initialisation is that when you play a video game and it ends, when you start a new game your score will be reset to 0.

To reset our movement counter, we will add a set variable block at the top of the stack of blocks, as shown below:


Now, run the Dancing Cat program a few times and you will notice that each time the number of movements variable will start at 0 and finish at 8.


Views
1 Total Views
1 Members Views
0 Public Views
Share on Social Networks
Share Link
Share by mail

Please login to share this webpage by email.