Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How to calculate the "distance from" with x an y ?
- moutamou
-
80 posts
How to calculate the "distance from" with x an y ?
How to calculate the “distance from” with x an y ?
- awesome-llama
-
1000+ posts
How to calculate the "distance from" with x an y ?
Pythagoras' theorem


which can be arranged to

In scratchblocks:

which can be arranged to
In scratchblocks:
set [dist v] to ([sqrt v] of (((x) * (x)) + ((y) * (y))))
Last edited by awesome-llama (Jan. 17, 2022 11:54:28)
- Opguy90
-
23 posts
How to calculate the "distance from" with x an y ?
(distance to [<(x position) and (y position)>])
Last edited by Opguy90 (Jan. 18, 2022 03:39:44)
- awesome-llama
-
1000+ posts
How to calculate the "distance from" with x an y ?
What do you mean? no it wont work bruh
- moutamou
-
80 posts
How to calculate the "distance from" with x an y ?
i mean for Opguy90, also the the x and y variables; for which sprite it is?
- deck26
-
1000+ posts
How to calculate the "distance from" with x an y ?
You need to know the x and y positions of each end of the distance you're measuring. If they're both sprites that's your answer. but if you want the distance between sprites there's a block for that so no need to do this. If you want to know how far a sprite is from a known x, y position then it's that's sprite position that needs comparing with the x,y coordiantes. i mean for Opguy90, also the the x and y variables; for which sprite it is?
- Discussion Forums
- » Help with Scripts
-
» How to calculate the "distance from" with x an y ?