Discuss Scratch

Tallented-Code-bot
Scratcher
100+ posts

distance to (x) (y) block

There should be a
(distance to x:() y:()::sensing)
block.
This would be useful, and even though there are workarounds, they are either too hard for beginers,
or use multiple sprites or variables. This block would return the distance from the center of the sprite
to the specified x and y position.
weegaweek
Scratcher
100+ posts

distance to (x) (y) block

this can be achieved with some maths:
([sqrt v] of ((([y] - (y position)) * ([y] - (y position))) + (([x] - (x position)) * ([x] - (x position)))))
you dont need extra variables or sprites.

(((((Do you have any spare poping tonic? I drank too much pushing potion, and now I'm stuck a few layers of parenthisis too deep.

Powered by DjangoBB