Page 94 - 2502_Pakistan-kifayat_C-8
P. 94
block: The block returns true if at least one of its inputs are true; if neither of them
are true, it returns false.
block: The block returns the opposite value of the Boolean input, reversing its value.
For example, to make a sprite say "You're clicking me!" only when the mouse is pressed and the mouse
pointer is touching the sprite, use the following script:
Nesting Conditions
Nesting means placing one block inside another block. This allows the program to check a second
condition only if the first condition is true, adding more detail to the decision-making process.
Nesting conditions helps organise complex choices step-by-step, which is very useful in games and
interactive projects with many rules.
For example, to move the sprite upwards until it touches the edge, and if it does, make it say 'Can't go
higher!', use the following script:
When green flag clicked block starts the program. Inside a forever loop, the program first checks using
an if () then, else block whether the Up arrow key is pressed and the sprite is not touching the edge If
both are true, it uses the change y by 10 motion block to move the sprite Up.
If this condition is false, another If () Then block checks if the Up arrow key is pressed and the sprite is
touching the edge. If true, the sprite uses the say Can’t go higher! for 2 seconds block to show a message.
92 Premium Edition-VIII

