Discuss Scratch
- Sigton
-
1000+ posts
Distance to (x) (y)
In other programming languages, a function would be defined so that you don't have to rewrite code, and this function can easily be added to a library so it can be used over and over again. It's not really that far fetched an idea. I won't support because this workaround is what's used in many other programming languages and it'd probably be a good thing for new Scratchers to learn the maths behind it.
Sigton
Last edited by Sigton (Oct. 24, 2017 17:58:11)
- Cub56
-
1000+ posts
Distance to (x) (y)
Most Scratchers are in middle school and up - see statistics Yes, but still you don't understand, the workaround is too long, it takes too much dragging of blocks, it's better to use one block alone. Most people probably aren't in middle school yet!
- Sigton
-
1000+ posts
Distance to (x) (y)
But we can't ignore the many million Scratchers younger than that.Most Scratchers are in middle school and up - see statistics Yes, but still you don't understand, the workaround is too long, it takes too much dragging of blocks, it's better to use one block alone. Most people probably aren't in middle school yet!
Sigton
- Charles12310
-
1000+ posts
Distance to (x) (y)
In other programming languages, a function would be defined so that you don't have to rewrite code, and this function can easily be added to a library so it can be used over and over again. It's not really that far fetched an idea. I won't support because this workaround is what's used in many other programming languages and it'd probably be a good thing for new Scratchers to learn the maths behind it.
Sigton
1. Yeah, it's better to use one block than to have to keep dragging to many blocks for just one function.But we can't ignore the many million Scratchers younger than that.Most Scratchers are in middle school and up - see statistics Yes, but still you don't understand, the workaround is too long, it takes too much dragging of blocks, it's better to use one block alone. Most people probably aren't in middle school yet!
Sigton
2. Exactly, just because there are many Scratchers in middle school and up, doesn't mean that this block isn't necessary. Of course we need to learn, but this isn't really the center of the universe for learning math. Just try something like Khan Academy (they teach almost everything, that is one thing I call the center of the universe for learning (i think)), and then see what you could do when you are coding. Also we can't ignore those million young Scratchers.
Last edited by Charles12310 (Oct. 25, 2017 00:19:44)
- FancyFoxy
-
500+ posts
Distance to (x) (y)
This is definitely useful, and the workaround is complicated enough. Fits my criteria, so support.
- -ShadowOfTheFuture-
-
1000+ posts
Distance to (x) (y)
This can be pretty useful, and the workaround is complicated. Support.
The workaround is just the distance formula.
The workaround is just the distance formula.
- Sigton
-
1000+ posts
Distance to (x) (y)
The maths behind the block can always be put in the description of the block in the help tab 
Sigton

Sigton
- UndeadSorcerer
-
100+ posts
Distance to (x) (y)
Most Scratchers are in middle school and up - see statistics Yes, but still you don't understand, the workaround is too long, it takes too much dragging of blocks, it's better to use one block alone. Most people probably aren't in middle school yet!
I'm older than many scratchers but I've still never learned the math behind the equation. Plus, many scratchers are very young.
Last edited by UndeadSorcerer (Oct. 26, 2017 23:09:15)
- Cub56
-
1000+ posts
Distance to (x) (y)
I don't think they're as young as most people think. Although most scratchers are at school it doesn't mean that it's all 5 year olds and we shouldn't sacrifice all of Scratch's complexity to cater to toddlers.Most Scratchers are in middle school and up - see statistics Yes, but still you don't understand, the workaround is too long, it takes too much dragging of blocks, it's better to use one block alone. Most people probably aren't in middle school yet!
I'm older than many scratchers but I've still never learned the math behind the equation. Plus, many scratchers are very young.
This is just like getting rid of the trigonometric functions because toddlers won't understand them.
Last edited by Cub56 (Oct. 27, 2017 12:39:57)
- Charles12310
-
1000+ posts
Distance to (x) (y)
Well, it's better to use one block than to have to use the same script more than once! You are still ignoring those millions of young people. I told you, this isn't the center of the universe for learning math. The workaround has stuff that is mostly middle schoolish, and that's that. It's better to have one block than to have to drag another group of blocks and then you realize you are doing it wrong while you do that (for some users). Otherwise, why do we have a distance to sprite block if it's workaround is:I don't think they're as young as most people think. Although most scratchers are at school it doesn't mean that it's all 5 year olds and we shouldn't sacrifice all of Scratch's complexity to cater to toddlers.Most Scratchers are in middle school and up - see statistics Yes, but still you don't understand, the workaround is too long, it takes too much dragging of blocks, it's better to use one block alone. Most people probably aren't in middle school yet!
I'm older than many scratchers but I've still never learned the math behind the equation. Plus, many scratchers are very young.
This is just like getting rid of the trigonometric functions because toddlers won't understand them.
([sqrt v] of (((((x position) - ([x position v] of [sprite v])) * ((x position) - ([x position v] of [sprite v]))) + (((y position) - ([y position v] of [sprite v])) * ((y position) - ([y position v] of [sprite v])))) :: operators )
(I am having a large headache for having to explain this stuff so many times…)
It's mostly the same thing, right?
- walkcycle
-
500+ posts
Distance to (x) (y)
With this it is easy to get the distance. You do not have to understand the math or drag out a bunch of scripts.define distance to (x) (y)
set [dx v] to ((x) - (x position))
set [dy v] to ((y) - (y position))
set [distance v] to ([sqrt v] of (((dx) * (dx)) + ((dy) * (dy))))
A nice and neat custom block for you
Simply put it in your backpack once and drag it out when you are ready to use.
And there is another way.
go to x: () y: () // sprite1
Have sprite1 go to the x,y position.
(distance to [sprite1 v]) // sprite2
Measure the distance to x,y from sprite2.
- DaEpikDude
-
1000+ posts
Distance to (x) (y)
You know, all of this will be resolved when 3.0 comes out with custom reporters. -snip-
Last edited by DaEpikDude (Oct. 27, 2017 20:57:25)
- platyjam
-
44 posts
Distance to (x) (y)
you cannot make custom reportersYou know, all of this will be resolved when 3.0 comes out with custom reporters. -snip-
- Sheep_maker
-
1000+ posts
Distance to (x) (y)
It was a misconception back then that Scratch 3.0 would be released with custom reporters (in reality, I believe they only stated they'd consider them)you cannot make custom reportersYou know, all of this will be resolved when 3.0 comes out with custom reporters. -snip-
Nonetheless, this could be implemented as part of an extension, but I think making users use the workaround is a good way of introducing to Scratchers how they can apply math (such as the Pythagorean theorem they learn in school) in programming
- 15-MinuteGaming
-
100+ posts
Distance to (x) (y)
It uses the Pythagorean theorem, which is learned in 4th-5th grade. Then, you just need to play with the values to get this formula. The age of scratch is 8-16, so only a tiny percentage of people would have trouble with this formula. Also, it is widely available throughout the internet.So, how do they even know if that script is gonna work? They don't understand how it works, why should we be expecting users to solve complicated problems and they aren't even in high school? I won't support because this workaround is what's used in many other programming languages and it'd probably be a good thing for new Scratchers to learn the maths behind it.
- CatsUnited
-
1000+ posts
Distance to (x) (y)
Support
CatsUnited - April 23, 2015
Since then, I've learnt Pythagoras and the distance formula and looking back at the suggestion, the distance formula shown isn't the hardest workaround to make, since it only looks big due to the padding of scratch blocks and a lack of an exponent operator, and seeing as American children learn Pythagoras from the beginning of middle school, that workaround covers most of the Scratch userbase. For the remaining users who either haven't learnt the distance formula, I think that using an invisible sprite and moving that to a coordinate so that your other sprite can get the distance from that using the (distance to [ v]) block should be sufficient for making basic games.
- --Explosion--
-
1000+ posts
Distance to (x) (y)
Please don't necropost, you are not adding anything to the discussion, if you support or do not support this suggestion please post why, but block spamming is not constructive ;Dsay [wow]