Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Measuring speed
- Bv141
-
New Scratcher
11 posts
Measuring speed
I have made a project where although the sprite moves a set number of steps, it's movement is modified by gravity and lift (it's a plane) so I cannot just work out it's speed by multiplying the steps.
Does anyone have any suggestions about how I could work out the accurate speed.
I have tried using the sine rule to work out a vector but it went horrifically wrong and I couldn't find any problems.
Does anyone have any suggestions about how I could work out the accurate speed.
I have tried using the sine rule to work out a vector but it went horrifically wrong and I couldn't find any problems.
- Bv141
-
New Scratcher
11 posts
Measuring speed
What do all the variables do? The speed=distance/time is what I need, but I have never got it to work
- Ted77775
-
Scratcher
1 post
Measuring speed
excuse me, Bv141 but can you please explain how? im trying to use it for a game. reply ASAP
- Madcatofdoom
-
Scratcher
500+ posts
Measuring speed
excuse me, Bv141 but can you please explain how? im trying to use it for a game. reply ASAPPlease don't necropost. Make your own topic!
- Barbeque_Sus
-
Scratcher
100+ posts
Measuring speed
um, but what are listsdon't necropost. make a topic
- King-Trisi
-
Scratcher
1 post
Measuring speed
bro i'm trying to findd a solution of meassuring speed in scratch
- Rscratchpro
-
Scratcher
6 posts
Measuring speed
Hello people!
I need help by measuring speed - When you move, then variable shows how fast speed it's moving.
It's for game
Thank you!
-Rsrcatchpro
I need help by measuring speed - When you move, then variable shows how fast speed it's moving.
It's for game
Thank you!
-Rsrcatchpro
- mmhmBeans
-
Scratcher
500+ posts
Measuring speed
(#12)Always create a new post when you need help, this topic is almost 10 years old.
Hello people!
I need help by measuring speed - When you move, then variable shows how fast speed it's moving.
…
Anyway, you need to save the previous position before moving and then compare them. Make sure that you copied the expression correctly. There isn't any built-in way of measuring distance between two points, so you'll have to use trigonometry.
when green flag clicked
forever
set [old x v] to (x position)
set [old y v] to (y position)
movement scripts::grey
set [speed v] to ([sqrt v] of ((((x position)-(old x))*((x position)-(old x)))+(((y position)-(old y))*((y position)-(old y)))))
- Rscratchpro
-
Scratcher
6 posts
Measuring speed
Hello people!
This is RSRCTACHPRO again
I found out!
And for these steps you will need one variable so let's call it “mouse movement”
First put when flag clicked (optional)
IMPORTANT! - Put another empty sprite. This wont work on your player's sprite
2. Put forever
3. Put Go to mouse-pointer make sure it's mouse pointer
4. Repeat (num) Make sure you put 1
5.Set to (distance to (mouse-pointer)
This is it
Enjoy! This measures how fast your mosue is moving and variable will show you
-Rscratchpro
This is RSRCTACHPRO again
I found out!
And for these steps you will need one variable so let's call it “mouse movement”
First put when flag clicked (optional)
IMPORTANT! - Put another empty sprite. This wont work on your player's sprite
2. Put forever
3. Put Go to mouse-pointer make sure it's mouse pointer
4. Repeat (num) Make sure you put 1
5.Set to (distance to (mouse-pointer)
This is it
Enjoy! This measures how fast your mosue is moving and variable will show you
-Rscratchpro
- Rscratchpro
-
Scratcher
6 posts
Measuring speed
Here's example
when green flag clicked
forever
go to [ mouse-pointer]
repeat (1)
set [ mouse movement] to (distance to [ mouse-pointer])
end
end
- Rscratchpro
-
Scratcher
6 posts
Measuring speed
Oops! Wrong code
when green flag clicked
foreverSorry for the mistake
go to [ mouse-pointer]
repeat (1)
end
set [ mouse movement] to (distance to [ mouse-pointer])
end
- Rscratchpro
-
Scratcher
6 posts
Measuring speed
mmhmBeans
How do i get Movement scripts block? I've never seen his block
How do i get Movement scripts block? I've never seen his block
- Cool_Dude2022
-
Scratcher
500+ posts
Measuring speed
mmhmBeans
How do i get Movement scripts block? I've never seen his block
Please do not necropost.
- Discussion Forums
- » Help with Scripts
-
» Measuring speed