Friday, 12 January 2018

2) Sensing Palette

Sensing Palette
 
Sensing blocks is color-coded light-blue and are used to detect different factors of a project. The controls avaolable here are used to communicate among sprites and with external hardware or programs.

There are 18 sensing blocks: 2 Stack blocks, 7 Boolean blocks and 8 Reporter blocks

1. Stack Blocks: It contains two blocks :



(i) The ask() and wait() block will create an input box with some text, shown at the bottom of the screen. User can input answer into it and submit it, The input is stored in the Answer block. The Answer block automatically updates to most recent input.

Activity:Move the sprite according to the steps entered by the user and the change the dress color also.

1. Add the following script using sensing block, motion block and looks block.


2. As the question appears along with sprite the user entered a number and sprite moves forward according to the entered steps.

3. Then the second question appears to enter the color (a numeric value). The sprite changes its dress color accordingly.



(ii) reset timer: Sets the timer to zero.

2. Boolean Blocks: It contains seven blocks :



The touching()? block checks if the sprite is touching the mouse-pointer, edge, or another sprite (a Reporter block holding the sprite's name can be used). It returns a true value if the sprite touches the selected object otherwise returns false. Every check for collisions with other sprites return false, however it still senses the mouse and the edges.

Activity: A sprite chase another sprite until first sprite touches the sprite.

1. Add the below script using sensing , control , motion and Look block. The sprite dog chase cat and display

“I caught you” when it catches the cat.




Other Blocks are:


Reports true if sprite is touching specified color
Click on color patch, then use eyedropper to select color
Reports true if first color (within sprite) is touching the second color (in background or another sprite)
Reports true if the mouse button is being pressed down
Reports true if the specified key is pressed
Reports true if computer microphone detects a sound volume greater than 30 (on scale of 1-100)
Reports true if specified sensor is pressed
To use this block, you need to have a “ScratchBoard” connected to your computer.



3. Boolean Blocks: It contains eight blocks :


The distance to () block reports the distance, in pixels, between it and the mouse-pointer or a specified sprite's costume center. If there is nothing in the drop-down insert of the block, or if a sprite that was deleted is still in the drop-down insert, it reports the distance as 0.

Activity: To find distance between two sprites write following script:


The distance between two sprites shown in the dialogue box.
The other clock available are:

Reports the x-position of the mouse-pointer
Reports the y-position of the mouse-pointer
Reports the value of the timer (in seconds)
Reports the volume (from 1-100) of sounds detected by the computer microphone
Reports the value of specified sensor. for this “ScratchBoard” must be connected to your computer.
Reports x coordinate, y coordinate, direction, costume, size and volume of the specified sprite.
Reports the answer to ask() and wait() block







No comments:

Post a Comment

1) Introduction to Email

Introduction to Email Introduction Communication, the transfer of information, has been the key element needed ...