Discuss Scratch

moutamou
Scratcher
80 posts

How to calculate the "distance from" with x an y ?

How to calculate the “distance from” with x an y ?
awesome-llama
Scratcher
1000+ posts

How to calculate the "distance from" with x an y ?

Pythagoras' theorem




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
Scratcher
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)

moutamou
Scratcher
80 posts

How to calculate the "distance from" with x an y ?

no it wont work bruh
awesome-llama
Scratcher
1000+ posts

How to calculate the "distance from" with x an y ?

moutamou wrote:

no it wont work bruh
What do you mean?
moutamou
Scratcher
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
Scratcher
1000+ posts

How to calculate the "distance from" with x an y ?

moutamou wrote:

i mean for Opguy90, also the the x and y variables; for which sprite it is?
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.

Powered by DjangoBB