Discuss Scratch
- UndeadSorcerer
- Scratcher
100+ posts
Distance to (x) (y)
For my tower defense game I think this will help. It might be useful for other things too!
Tell me if you support!
Also if there is any way to get around this please tell me.
(distance to x:() y:()::sensing)
Tell me if you support!
Also if there is any way to get around this please tell me.
- stickfiregames
- Scratcher
1000+ posts
Distance to (x) (y)
Support, the workaround is very long:
([sqrt v] of ((((x :: grey) - (x position)) * ((x :: grey) - (x position))) + (((y :: grey) - (y position)) * ((y :: grey) - (y position))))
- zacadoole1
- Scratcher
100+ posts
Distance to (x) (y)
Support, but for an alternate workaround couldn't you just have a hidden sprite at the location you want to find the distance from, then use the "distance to " block? Support, the workaround is very long:([sqrt v] of ((((x :: grey) - (x position)) * ((x :: grey) - (x position))) + (((y :: grey) - (y position)) * ((y :: grey) - (y position))))
Last edited by zacadoole1 (April 23, 2015 18:46:24)
As of 9/25/16 I run Firefox 47.0.1 (64-bit) with Flash Plugin v23.0 r0 on Windows 10 (Anniversary Update).
Click here to give me an internet! You know, if you want to. No pressure…
Joey James Jr. is my spirit animal. <3
- stickfiregames
- Scratcher
1000+ posts
Distance to (x) (y)
You could, but then of course you need another sprite and have to use broadcasts.Support, but for an alternate workaround couldn't you just have a hidden sprite at the location you want to find the distance from, then use the "distance to " block? Support, the workaround is very long:([sqrt v] of ((((x :: grey) - (x position)) * ((x :: grey) - (x position))) + (((y :: grey) - (y position)) * ((y :: grey) - (y position))))
- zacadoole1
- Scratcher
100+ posts
Distance to (x) (y)
Yeah, but it's easier for me to remember than all those math blocks!You could, but then of course you need another sprite and have to use broadcasts.Support, but for an alternate workaround couldn't you just have a hidden sprite at the location you want to find the distance from, then use the "distance to " block? Support, the workaround is very long:([sqrt v] of ((((x :: grey) - (x position)) * ((x :: grey) - (x position))) + (((y :: grey) - (y position)) * ((y :: grey) - (y position))))
As of 9/25/16 I run Firefox 47.0.1 (64-bit) with Flash Plugin v23.0 r0 on Windows 10 (Anniversary Update).
Click here to give me an internet! You know, if you want to. No pressure…
Joey James Jr. is my spirit animal. <3
- Prinseskat
- Scratcher
1000+ posts
Distance to (x) (y)
Easy to remember if you know how it works.Yeah, but it's easier for me to remember than all those math blocks!You could, but then of course you need another sprite and have to use broadcasts.Support, but for an alternate workaround couldn't you just have a hidden sprite at the location you want to find the distance from, then use the "distance to " block? Support, the workaround is very long:([sqrt v] of ((((x :: grey) - (x position)) * ((x :: grey) - (x position))) + (((y :: grey) - (y position)) * ((y :: grey) - (y position))))
lol the block's going out of the quote section
Last edited by Prinseskat (April 23, 2015 19:10:23)
haha funny kumquat meme
- zacadoole1
- Scratcher
100+ posts
Distance to (x) (y)
Oh, I could probably memorize it if I really wanted to, but you know what they say, you can't teach an old dog new tricks!Easy to remember if you know how it works.Yeah, but it's easier for me to remember than all those math blocks!You could, but then of course you need another sprite and have to use broadcasts.Support, but for an alternate workaround couldn't you just have a hidden sprite at the location you want to find the distance from, then use the "distance to " block? Support, the workaround is very long:([sqrt v] of ((((x :: grey) - (x position)) * ((x :: grey) - (x position))) + (((y :: grey) - (y position)) * ((y :: grey) - (y position))))
As of 9/25/16 I run Firefox 47.0.1 (64-bit) with Flash Plugin v23.0 r0 on Windows 10 (Anniversary Update).
Click here to give me an internet! You know, if you want to. No pressure…
Joey James Jr. is my spirit animal. <3
- stickfiregames
- Scratcher
1000+ posts
Distance to (x) (y)
It would be easier if we had a power block too:Oh, I could probably memorize it if I really wanted to, but you know what they say, you can't teach an old dog new tricks!Easy to remember if you know how it works.Yeah, but it's easier for me to remember than all those math blocks!You could, but then of course you need another sprite and have to use broadcasts.Support, but for an alternate workaround couldn't you just have a hidden sprite at the location you want to find the distance from, then use the "distance to " block? Support, the workaround is very long:([sqrt v] of ((((x :: grey) - (x position)) * ((x :: grey) - (x position))) + (((y :: grey) - (y position)) * ((y :: grey) - (y position))))
([sqrt v] of ((((x :: grey) - (x position)) ^ (2) :: operators) + (((y :: grey) - (y position)) ^ (2) :: operators))Still long though.
- Seapats
- Scratcher
70 posts
Distance to (x) (y)
Support, the workaround is very long:([sqrt v] of ((((x :: grey) - (x position)) * ((x :: grey) - (x position))) + (((y :: grey) - (y position)) * ((y :: grey) - (y position))))
Yes I used this for a project this would really help!
Three things i dislike:
1. Lists
2. Signatures
4. Irony
5. When people say they only are going to say 3 things then say 4.
- MegaApuTurkUltra
- Scratcher
1000+ posts
Distance to (x) (y)
Support. This would help new scratchers who don't want to use the “complicated” workaround.
$(".box-head")[0].textContent = "committing AT crimes since $whenever"
- Dobbatron
- Scratcher
3 posts
Distance to (x) (y)
This needs the formula:
SQRT of Xposition of one sprite - X position of other sprite * Xposition of one sprite - X position of other sprite + yposition of one sprite - y position of other sprite * yposition of one sprite - y position of other sprite
Hope this helped!
SQRT of Xposition of one sprite - X position of other sprite * Xposition of one sprite - X position of other sprite + yposition of one sprite - y position of other sprite * yposition of one sprite - y position of other sprite
Hope this helped!
Last edited by Dobbatron (Oct. 23, 2017 18:06:48)
- Cub56
- Scratcher
1000+ posts
Distance to (x) (y)
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.
Check out Life Raft Survival, my new advanced sandbox survival game with crafting, building, transportation, weather events, tropical storms, and more!
In the game you're stranded at sea after a mysterious crash and must survive in an unforgiving tropical island environment collecting resources and crafting, in an attempt to finally be rescued.
In the game you're stranded at sea after a mysterious crash and must survive in an unforgiving tropical island environment collecting resources and crafting, in an attempt to finally be rescued.
- Charles12310
- Scratcher
1000+ posts
Distance to (x) (y)
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.
A few internet communication companies want to corrupt the internet by getting rid of net neutrality. Stop Them!
- walkcycle
- Scratcher
500+ posts
Distance to (x) (y)
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.
I agree, it is a great opportunity to learn the math of distance.
That's excellent.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
Sigton
Another work round
go to x: () y: () // sprite1
(distance to [sprite1 v]) // sprite2
So, how do they even know if that script is gonna work?
By testing.
- Charles12310
- Scratcher
1000+ posts
Distance to (x) (y)
Yes but that's like saying the workaround is easy. -_-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.
I agree, it is a great opportunity to learn the math of distance.That's excellent.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
Sigton
Another work roundgo to x: () y: () // sprite1
(distance to [sprite1 v]) // sprite2So, how do they even know if that script is gonna work?
By testing.
The workaround is difficult, not everyone knows how it works, and I don't think everyone's gonna remember. I know about square roots but I can't even remember either. It's better to drag one block than to drag so many blocks and type so many stuff and then you realized that you forgot everything.
A few internet communication companies want to corrupt the internet by getting rid of net neutrality. Stop Them!
- Cub56
- Scratcher
1000+ posts
Distance to (x) (y)
It is only Pythagoras and I learnt it practically at the start of the equivalent of middle school.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.
Check out Life Raft Survival, my new advanced sandbox survival game with crafting, building, transportation, weather events, tropical storms, and more!
In the game you're stranded at sea after a mysterious crash and must survive in an unforgiving tropical island environment collecting resources and crafting, in an attempt to finally be rescued.
In the game you're stranded at sea after a mysterious crash and must survive in an unforgiving tropical island environment collecting resources and crafting, in an attempt to finally be rescued.
- Charles12310
- Scratcher
1000+ posts
Distance to (x) (y)
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!
A few internet communication companies want to corrupt the internet by getting rid of net neutrality. Stop Them!