Discuss Scratch

Sigton
Scratcher
1000+ posts

Distance to (x) (y)

Cub56 wrote:

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.
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.

Sigton

Last edited by Sigton (Oct. 24, 2017 17:58:11)

Cub56
Scratcher
1000+ posts

Distance to (x) (y)

Charles12310 wrote:

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!
Most Scratchers are in middle school and up - see statistics
Sigton
Scratcher
1000+ posts

Distance to (x) (y)

Cub56 wrote:

Charles12310 wrote:

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!
Most Scratchers are in middle school and up - see statistics
But we can't ignore the many million Scratchers younger than that.

Sigton
Charles12310
Scratcher
1000+ posts

Distance to (x) (y)

Sigton wrote:

Cub56 wrote:

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.
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.

Sigton

Sigton wrote:

Cub56 wrote:

Charles12310 wrote:

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!
Most Scratchers are in middle school and up - see statistics
But we can't ignore the many million Scratchers younger than that.

Sigton
1. Yeah, it's better to use one block than to have to keep dragging to many blocks for just one function.
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
Scratcher
500+ posts

Distance to (x) (y)

This is definitely useful, and the workaround is complicated enough. Fits my criteria, so support.
-ShadowOfTheFuture-
Scratcher
1000+ posts

Distance to (x) (y)

This can be pretty useful, and the workaround is complicated. Support.

The workaround is just the distance formula.
Sigton
Scratcher
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
UndeadSorcerer
Scratcher
100+ posts

Distance to (x) (y)

Cub56 wrote:

Charles12310 wrote:

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!
Most Scratchers are in middle school and up - see statistics

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
Scratcher
1000+ posts

Distance to (x) (y)

UndeadSorcerer wrote:

Cub56 wrote:

Charles12310 wrote:

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!
Most Scratchers are in middle school and up - see statistics

I'm older than many scratchers but I've still never learned the math behind the equation. Plus, many scratchers are very young.
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.

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
Scratcher
1000+ posts

Distance to (x) (y)

Cub56 wrote:

UndeadSorcerer wrote:

Cub56 wrote:

Charles12310 wrote:

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!
Most Scratchers are in middle school and up - see statistics

I'm older than many scratchers but I've still never learned the math behind the equation. Plus, many scratchers are very young.
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.

This is just like getting rid of the trigonometric functions because toddlers won't understand them.

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:

([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
Scratcher
500+ posts

Distance to (x) (y)

Sigton wrote:

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
With this it is easy to get the distance. You do not have to understand the math or drag out a bunch of scripts.

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
Scratcher
1000+ posts

Distance to (x) (y)

Charles12310 wrote:

-snip-
You know, all of this will be resolved when 3.0 comes out with custom reporters.

Last edited by DaEpikDude (Oct. 27, 2017 20:57:25)

platyjam
Scratcher
44 posts

Distance to (x) (y)

loads and loads of support
platyjam
Scratcher
44 posts

Distance to (x) (y)

DaEpikDude wrote:

Charles12310 wrote:

-snip-
You know, all of this will be resolved when 3.0 comes out with custom reporters.
you cannot make custom reporters
Sheep_maker
Scratcher
1000+ posts

Distance to (x) (y)

platyjam wrote:

DaEpikDude wrote:

Charles12310 wrote:

-snip-
You know, all of this will be resolved when 3.0 comes out with custom reporters.
you cannot make custom reporters
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)

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
Scratcher
100+ posts

Distance to (x) (y)

Charles12310 wrote:

Cub56 wrote:

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.
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?
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.
CatsUnited
Scratcher
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.
italylan
Scratcher
6 posts

Distance to (x) (y)

say [wow]
italylan
Scratcher
6 posts

Distance to (x) (y)

when green flag clicked
clear
pen up
--Explosion--
Scratcher
1000+ posts

Distance to (x) (y)

italylan wrote:

say [wow]
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 ;D

Powered by DjangoBB