<< Chapter < Page | Chapter >> Page > |
Image 13 shows the programming blocks that are exposed by clicking the Motion button at the top left of Image 4 .
You saw three of the blocks from Image 13 being used in Image 6 , Image 7 , and immediately below the top tan block in the bottom script in Image 8 . Now we need to use another of the blocks from Image 13 .
Recall that the blue point in direction block in the top script in Image 8 causes the basketball to turn to face to the right when the user clicks the green flag.
The two turn blocks in the bottom script in Image 8 cause the basketball to rotate around its center by 180 degrees. This, in turn,causes it to face in the opposite direction from the direction that it was previously facing. (It also turns it upside down, but that doesn't matter for a round basketball.)
This is the action that is required whenever either of the touching blocks is true. In other words, whenever the basketball touches either of the beach balls, it must turn to facethe opposite direction and be prepared to move 90 steps in that direction the next time the user clicks the basketball.
A copy of this program has been posted online for your review (see Resources for the URL) . If you don't find the program using that URL, search the Scratch site for the usernamed dbal.
I encourage you to use the information provided above to write this program. Experiment with the code, making changes, and observing the results of yourchanges. Make certain that you can explain why your changes behave as they do.
Just for fun, use blocks from the purple Sound group and add some sound effects to your program.
I also encourage you to write the program described below.
Write a Scratch program named IfWithVar01 that produces the output shown in Image 14 when the user clicks the green flag.
When the user clicks the green flag, a DrawingPencil sprite draws a pair of orthogonal axes that intersect at the origin in the white Stage area.Make the horizontal axis extend from -200 to 200. Make the vertical axis extend from -100 to 100.
Each time the user clicks the mouse in the white Stage area (after the user has clicked the green flag) , a straight line is drawn from the current location of the DrawingPencil to the location where the mouse click occurred. Image 15 shows an example output after two mouse clicks.
In case you need to sneak a peek at the solution to this programming project, a copy of this program has been posted online for your review (see Resources for the URL) . (If you don't find the program using that URL, search the Scratch website for the usernamed dbal .)
Notification Switch
Would you like to follow the 'Teaching beginners to code' conversation and receive update notifications?