Discuss Scratch

sealifefriend
Scratcher
500+ posts

How do you use the 'sensing' blocks?

Hi there! Thank u for reading this! So I'm kind of new to intermediate coding. (In my mind there are beginner, intermediate, and advanced coding lol. I would say I just graduated from beginner) I mean the more I look at games and stuff the more I learn but I just don't understand the sensing blocks. The only one I know and have used is the ‘ask a question and u answer’ one. Oh, and the last operating ones I don't know how to use either. Like the mod, round, abs of-, sorry if thats confusing. Any tips? They would be greatly appreciated.
_______________________________
Tigerclaw- Grr…go away
Bluestar- Hi…why are u here
Leopardstar- Hello…what do u want?
Firestar- HELLO!! Come on in!
idk…the world of warriors… XD
Ihatr
Scratcher
1000+ posts

How do you use the 'sensing' blocks?

Here are the most used ones
<touching [ v] ?> Returns true or false if this sprite is touching another
<touching color [#bf1e45] ?> Returns true or false if this sprite is touching another
<color [#00a96d] is touching [#15ec73] ?> Returns true or false if this sprite is touching a color
(distance to [ v]) Returns the distance to a certain sprige
ask [] and wait
(answer) Returns what the user answered to a question
<key [ v] pressed?> Returns true or false if a key is pressed
<mouse down?> Returns true or false if the mouse is down
(mouse x) Returns the x position of the mouse
(mouse y) Returns the y position of the mouse
sealifefriend
Scratcher
500+ posts

How do you use the 'sensing' blocks?

Thank you! That was helpful!
codingcoder1010
Scratcher
46 posts

How do you use the 'sensing' blocks?

ok so sensing blocks do what they sound like, they sense changes in the sprite. Also they sense keys you press.

For example,
<key [ v] pressed?>
.

will sense what key you are pressing and you can make it sense any key, like the D.
You can use this in games by using that block and making your character move right.
.

if <key [d] pressed?> then
change y by (10)
.
so yeah, sensing can be used to detect keys being pressed.
but also it can detect sprites touching specific colors.
with the
<touching color [#0a255a] ?>
.
OR
.
<color [#f891ea] is touching [#a803ec] ?>
.

you can use these to end games, but it is not limited to that.

I hope this helps!

Last edited by codingcoder1010 (Sept. 6, 2020 20:13:22)

sealifefriend
Scratcher
500+ posts

How do you use the 'sensing' blocks?

bump
ScratchLetters2020
Scratcher
100+ posts

How do you use the 'sensing' blocks?

sealifefriend wrote:

Hi there! Thank u for reading this! So I'm kind of new to intermediate coding. (In my mind there are beginner, intermediate, and advanced coding lol. I would say I just graduated from beginner) I mean the more I look at games and stuff the more I learn but I just don't understand the sensing blocks. The only one I know and have used is the ‘ask a question and u answer’ one. Oh, and the last operating ones I don't know how to use either. Like the mod, round, abs of-, sorry if thats confusing. Any tips? They would be greatly appreciated.

Here are some blocks:

<key [ v] pressed?> // Senses the key that you're pressing (Senses letters, numbers, and arrow keys ONLY)
(answer) // Latest answer to a question
([abs v] of ()) // Absolute value (distance from 0)
(() mod ()) // Reports the remainder of a division problem
(round ()) // Rounds a decimal to an integer

Last edited by ScratchLetters2020 (Sept. 14, 2020 23:21:59)

fdreerf
Scratcher
1000+ posts

How do you use the 'sensing' blocks?

ScratchLetters2020 wrote:

(() mod ()) // Checks if the first number is divisible by the second number

That's not exactly what the mod block does.
It reports the remainder of dividing the two numbers. It reports 0 if they can be divided evenly as there is no remainder.

For instance, 63 does not divide into 5 evenly. Doing so by hand on paper gives an answer of 12, with a remainder of 3. That 3 is what (63) mod (5) would report.

Powered by DjangoBB