Session 9:

Working Plan

  • Conditional structure
  • Logical expressions
  • Operators and sensing
  • Questions and answers

Let’s condition de movements

Pas a pas Step by step

  • Sign in and open the project m1repte71 that we created in session 7.
  • Click on File and choose the option Save as a copy.
    Menú fitxer
  • Now we have a project called m1repte71copy. Change the name to m1repte91.
  • Now, change the size of the dragon bigger.
    Drac creix
  • We have checked the category Control. Now let’s have a look at the conditional structures:
    Estructures condicionals
  • Add a condition. You can use the block if … then:
    Si ... llavors
  • The blocks with pointed ends are logical expressions, which can be true or false. We can find them in the categories Operators and Sensing.
  • We will add the dragon an initial control to set size at 100% and add a condition to stop growing when touching the wizard:
    Drac creix amb límit

Icona repte Repte 1

Modify the project m1repte91 to make the dragon stop growing if he touches de wizard or if we press a key.
Expressió lògica o expressió lògica


The Scratch asks questions!

Pas a pas Step by step

  • let’s go on working on the projetc m1repte91
  • In the category Control there is another conditional block:
    Si ... llavors ... si no ...
  • Choose the wizard. He will ask a question. Modify the programme and add the following:
    Pregunta i espera
  • Write the following in this block: “Do you give up? Say Y if it is Yes and  N if it is No”.
  • When we write the answer it is saved in a place called answer:
    Resposta
  • In order to pregramme the two possible answers, we must do the following:
    Comparació
    Programa condicional amb si ... si no