Discuss Scratch

hello2248
Scratcher
100+ posts

Distance to (x) (y) script

could someone help me with making that please? I need it for my game, it would just calculate the distance between a sprite and a coordinate.

define distance to (x) (y)
qazqweplm
Scratcher
19 posts

Distance to (x) (y) script

You could make an invisible sprite, make it go to the xy location, then use the sensing value block (distance to _).
footsocktoe
Scratcher
1000+ posts

Distance to (x) (y) script

There are no blocks for pure coordinates. There has to be something there and then you use the coordinates of that. Use a one pixel sprite and you can make it invisible like @qazqweplm suggested by giving it a ghost effect of 100. Don't forget to put the costume center dead on it.
hello2248
Scratcher
100+ posts

Distance to (x) (y) script

ok, thanks.
gtoal
Scratcher
1000+ posts

Distance to (x) (y) script

hello2248 wrote:

could someone help me with making that please? I need it for my game, it would just calculate the distance between a sprite and a coordinate.

define distance to (x) (y)

Remember pythagoras?

crisostimo
Scratcher
500+ posts

Distance to (x) (y) script

I remember Pythagoras.

define distance to (x) (y)
set [Calculated Distance v] to ([sqrt v] of (( ((x position) - (x)) * ((x position) - (x)) ) + ( ((y position) - (y)) * ((y position) - (y)) )))

Last edited by crisostimo (Dec. 30, 2015 04:54:03)

hello2248
Scratcher
100+ posts

Distance to (x) (y) script

Thank you so much! will give credit
superl2
Scratcher
39 posts

Distance to (x) (y) script

Thanks

Powered by DjangoBB