Changing what is in the box
A box holds 0. Each tap must make it bigger by one.
score holds 4. Step 1 of 3
scoreholds 4.- Read 4. Work out 5.
- Write 5 back. The 4 is gone.
The block says add 1 to score.
The first run changed the box from 4 to 5. Start the block again and the box holds 6, not 5. The second run starts from 5, so 5 + 1 = 6.
Rule: An add block reads the number in the box. It works out the new number. It writes that back.
A repeat block runs its inside blocks a set number of times. Put an add block inside it. The box starts at 0. Repeat 4 times, add 3: the box holds 3, 6, 9, 12.
Watch out!
score = score + 1 is not a Maths equation. It is an order: read the box, then write the new number.
Slide the two numbers. Make score end at 12.
Loading lab…