2015-06-10

Learning Scratch (1)

I teach Scratch [1], a computer programming language, to 10 to 12 years old students from last year. Sometimes they show me an interesting creative idea. I would like to write one of them here.

Before I explain what my students did, I will explain what is Scratch. First I will explain it in a conceptual way, then with an example. If someone can understand a conceptual explanation, he/she can apply the idea to many cases, but this is a bit difficult since their understanding must be deep. An explanation by example is rather easy to understand since it is shallow, that means you don't know it is still true in other cases. So there is a trade-off.

Scratch is a computer language, but also a programming environment.  In the environment, the developer writes event driven programs to control many sprite [2] characters. You can think each sprite character an object. Each event invokes a program and each program runs in parallel.

Maybe this explanation doesn't make sense for whom has never written a program. There are many conceptual words here: programming environment, sprite, event, object, and so on.. Each term is a concept in programming and we need to lean them. But I usually don't explain these concepts to 10 years old students. So I use examples. But I hope they can understand the concept in the future.

When you start scratch programming environment, there is a cat (Figure 1).  The developer writes a program what the cat does when something happened. ``Something happened'' means, for instance, a key is pushed, a mouse button is pushed. These ``something happened'' is called an ``event.'' An event starts a program. Such program can also create other events. This type of program is called an event driven program. Each character, for instance, a cat, a dog, and so forth, usually has an own state. The developer uses this state to write a program. Here ``a state'' is for example, where is the cat (position), which direction the cat is looking at (directional angle). An object is a programming instance that has a state. Here, you can consider that a cat is an object, a dog is also an object.
Figure 1. Scratch programming environment
In the scratch environment, the green flag button is the start button of the program. Most of the scratch programs use this green flag as the start event. For example, when the green flag button is pushed, the cat moves to the center of the screen and says ``Hello!'' I usually first tell my students about ``a coordinate system.'' My explanation is simple as ``x'' means left or right, ``y''means up or down. If you set both value to 0, the character moves to the center of the screen. When you make the x value large, the character moves to the right. In the scratch environment, the coordinates x and y are always shown. So I can show how the coordinates change as I move the character. When I catch the cat by the mouse (I mean a computer mouse), I say ``See, when the cat move to the right, the x value becomes larger.''  I drag the cat and move it around to show them.

This time I explained briefly what is Scratch. In the next blog entry, I would like to talk about 10 years old student story who made a character animation program on Scratch.

References

No comments: