<< Chapter < Page | Chapter >> Page > |
Repetitively clicking the mouse in the Stage area causes the Counter variable to count down in increments of oneand causes the counter variable to count down in increments of five.
The ability to write programs that cause certain operations to occur in response to events (such as pressing the space bar and clicking the mouse on the Stage) is often referred to as event-driven programming.
It is easy to write event-driven programs in Scratch. On the other hand, writing event-driven programs is not so easy in languages such asJava, C#, and C++. You need quite a lot of programming knowledge to write event-driven programs in those languages.
It is useful to give programming students a taste of event-driven programming early, if for no other reason than the factthat it tends to make programming more interesting.
The blocks shown in Image 4 are not used in this program. They are shown in this module to illustrate blocks with pointed endsreferred to earlier .
I encourage you to use the information provided above along with the Scratch 2.0 programming interface shown in Image 1 to write and run 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.
A copy of this program has been posted online for your review.
I also encourage you to write the programs described below.
The following projects are designed to:
Begin with the program named Variable01 and modify it to create a new program named Variable02 . Modify the original program in such a way that pressing the space bar five times in succession, (after clicking the green flag to set both variables to zero) , will cause the displayed values of the variables named Counter and counter to be as shown in Image 5 .
Having reached that point, clicking the mouse five times in succession in the Stage area will cause the displayed values of the variables named Counter and counter to be as shown in Image 6 .
A copy of this program is posted online for your review.
You should successfully complete Project 1 before attempting this project. Begin with the program named Variable01 and modify it to create a new program named Variable03 . Modify the original program in such a way that pressing the space bar five timesin succession, (after clicking the green flag to set both variables to zero) , will cause the displayed values of the variables named Counter and counter to be as shown in Image 7 .
Notification Switch
Would you like to follow the 'Teaching beginners to code' conversation and receive update notifications?