Fifth Scenario: Sensing & Operators

Quick References for all Sensing blocks

Quick References for all Operators blocks

Sensing

Operators

Boolean< blocks >

These <diamond shape blocks> are <boolean> blocks that check a condition and return True or False. You probably see some examples in the Event Session already. Imaging you are asking your sprite or computer Yes or No questions "Do you touch the mouse pointer?", "Did someone press the space key? ", "Is this number equal to 50? "or "Does the word apple contain an A?". The answers to these questions can only be Yes/True or No/False, and there is no status in between. These blocks represent the answer to the question at the moment the block ran

Boolean Operators

Boolean operators calculate a new boolean with boolean values. 

<boolean A> and <boolean B> can only be True when both of them are True, otherwise it will be False.  

<boolean A> or <boolean B> will be True when either of them are True, otherwise it will be False.  

Not <Boolean B> will flip B from Ture to False.

touching (mouse/edge/sprite/color)?

color (color) is touching (color)?

These blocks only detect whether the sprite with the code block has contact with the mouse, edge, another sprite, or a certain color.

Example: 

repeat until <touching color (red)>:

glide (0.5) secs to mouse-pointer

if color(orange) is touching color(red):

(the first color need to be from the sprite)

Click the green flag to start.

Click the cat to create a clone(copy) of it. 

Wait for one clone that touches the edge. Click the mouse anywhere, it will switch to Tree background. Here the cat will move with your mouse pointer to find the flower. After getting the flower(touching color red), it will stop all scripts and end this game.


Sensing

Value ( blocks )

These (oval shape blocks) are (value) blocks that store a number or a string(text).  This rule also applies to other oval shape blocks in Scratch.

The sensing blocks will get the value automatically either from your device (mouse, microphone, and time) or from your game (answers, backdrop, username).  

The operator blocks require you to choose one or more values to calculate a new value as the result of an expression. For example, (pick random (1) to (10)) will give you a number from 1 to 10 (including 1 and 10) randomly. Join(apple)(banana) will give you a new string "applebanana".

Operators