Processing math: 100%

Prijavi problem


Obeleži sve kategorije koje odgovaraju problemu

Još detalja - opišite nam problem


Uspešno ste prijavili problem!
Status problema i sve dodatne informacije možete pratiti klikom na link.
Nažalost nismo trenutno u mogućnosti da obradimo vaš zahtev.
Molimo vas da pokušate kasnije.

Procedures

We don’t have to create the program as a whole.

It is far more clear if we divide pieces of code into smaller, separate parts - procedures. Defining procedures makes writing programs and finding mistakes easier. That is why it is good to keep the procedures in your “backpack”. That way, you will be able to use them in other programs you create, and not waste time on making them again.

Broadcasting

Programs made in Scratch usually have multiple sprites that interact with each other. We can define the interaction ourselves, and we can also use the built-in procedure That allows the sprites to broadcast messages and affect the running of the program. Using the broadcasting procedure will significantly decrease the number of blocks in the program, and it will make it easier for us to read the code.

_images/ProcZ1a.png _images/ProcZ1b.png

Q-7: There are two programs - A and B, presented in the figures above. Both programs contain 3 sprites, girls speaking English, German and French. Below each girl are blocks that belong to them (the blocks allow them to say hello to the other two in their own language). Create programs you see in the figures above. Analyze what happens when they run. Which program represents a simulation of a normal (regular) conversation between three strangers?




Defining a new procedure

In Scratch, we can create a new procedure that would correspond to our needs.

Imagine that we want to create a program, which draws a flower on the stage. A flower is made of petals. Therefore, we need two procedures:

  • Petal, within which we will define the drawing of one petal, and

  • Flower, within which we will define the drawing of five petals.

In other words, the procedure Flower will call the procedure Petal, and the main program will call the procedure Flower.

We create a procedure by clicking on the category My Blocks, where we should click on the button Make a Block. A window will open, which will allow us to name our procedure.

_images/ProcLatica.png

If you want your flower to have the same petals like the one in the figure below, create the procedure Petal we presented:

_images/KodProcLatica.png

Uradi We will let you make a procedure, which draws 5 petals. Little help: After drawing one petal, you need to turn the sprite 72 degrees to the right.

Vazno So, by using procedures, we make writing programs and finding mistakes easier.