Discuss Scratch

bot_of_life
Scratcher
6 posts

How does the distance to (Sprite) block work?

I am trying to make a scrolling game but need to find how the “Distance to ___” reporter block works, if you know, can you please reply with the answer (as in the formula)

Last edited by bot_of_life (April 28, 2023 15:13:51)

iiDk__
Scratcher
100+ posts

How does the distance to (Sprite) block work?

(distance to [Sprite1 v]) // outputs the distance between the sprite the block is in to the sprite in the dropdown
if <(distance to [item v]) < [10]> then
pickup item :: custom
end
PhiPhenomenon
Scratcher
500+ posts

How does the distance to (Sprite) block work?

It won't work for your scrolling game. The block uses the x and y position of the sprites on the screen and the distance formula:

define Distance between sprites (x1) (y1) (x2) (y2)
set [distance v] to ([sqrt v] of ((((x2) - (x1)) * ((x2) - (x1))) + (((y2) - (y1)) * ((y2) - (y1)))))

Last edited by PhiPhenomenon (April 28, 2023 15:17:14)

him338
Scratcher
4 posts

How does the distance to (Sprite) block work?

i do not know
No i dont want to be quoted in a comment my brother made!

Powered by DjangoBB