<< Chapter < Page | Chapter >> Page > |
I recommend that you open another copy of this module in a separate browser window and use the following links to easily find and view the imageswhile you are reading about them.
In an earlier module, I told you that any programming logic problem could be solved using an appropriate combination of only three programming structures,none of which are complicated. The three structures are known generally as:
I have explained the sequence and selection structures and some of the loop structures in earlier modules. I will continue to concentrate on the loopstructure in this module.
In this module, I will present and explain the following three Scratch programs:
In addition, I will provide the specifications for a student-programming project for you to demonstrate your understanding of what you learned from thethree programs listed above and from earlier modules.
This program illustrates the use of a forever block in conjunction with an if block. When the user clicks the green flag, the program implements the pseudocode shown in Image A .
Move the cat to the center of the stage.
Turn the cat to face to the right.while(true){//infinite loop
if(space bar is pressed){Change cat to next costume image
Move cat forward 10 steps.Wait 0.1 seconds.
Turn cat clockwise 15 degrees.}//end if statement
}//end infinite while loop
If the space bar is pressed, the cat moves around the circumference of a small circle, appearing to walk due to the visual effect produced by switchingbetween two images (known in Scratch as costumes) . As explained in a previous module,the two costumes were designed to produce the illusion of walking.
The code for the older Scratch v1.4 version of this program is shown in Image B .
Notification Switch
Would you like to follow the 'Teaching beginners to code' conversation and receive update notifications?