Scratch Programming

advertisement
Scratch Programming
Lesson 2
First glance to programming logic
We are going to learn…
• How to use repeat loop
▫ How to use pen
•
•
•
•
How to use repeat-until loop
If…. Logic
How to use forever loop
How to stop a program
Repeat loop
• The command inside the repeat loop will repeat
n times which is depending on the number
stated
• The loop will not stop until the designated
number of times is finished
How to use pen?
Clear all thing that drawn on the stage
Put down the pen to start drawing
OR
Take the pen up to stop drawing
Determining the colour of the pen
Change the pen size to change the thickness
of the line
Copy the image of the sprite and print on
the stage
Repeat-until loop
• The command inside the loop will be repeated
until the operation box
return a TRUE value
e.g.
In this loop, the sprite will keep on changing
colour until it touches the mouse-pointer.
If…
• The
trapezium indicates that an operation
is required.
• Operation: return TRUE or FALSE value
E.g.
• If… The loop will run if the operation is true
Forever loop
• Usually, it uses with a starter
▫ e.g.
How to stop a program?
Task of the lesson
•
•
•
•
Edit Program1_3_ _ _
Use the Green Flag to start the program
Add one more character to the program
Once the program start, the newly added character
will change colour continuously UNTIL it is touched
by the original character
• If the two characters touch
▫ The new character will draw a pattern (either triangle,
square or a start) with a pen
▫ a sound differs from the original one will emit then the
whole program will end
Download