This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2009-04-20 14:00:03

demosthenes
Retired Community Moderator
Registered: 2008-02-19
Posts: 1000+

Velocity

"Velocity" is just the name of a variable, just because it is named velocity doesn't make a difference.
However, if you want to know how to use velocity in one of your games I can help.
    Let's start with "Y Velocity":
Using yVelocity will help if you want to make good jumping scripts for your games.
To start this session of testing arrange the stage like this:
http://img144.imageshack.us/img144/416/stage.gif
If the image doesn't load go to this link: http://img144.imageshack.us/my.php?image=stage.gif
Then in the Cat sprite make this script:
http://img213.imageshack.us/ifs/2088/img519/3/picture4kef.png
If the image doesn't load go to this link: http://img519.imageshack.us/my.php?image=picture4kef.png
Text of the comment block (if you can't read it):
This is a basic jumping script. We'll start by breaking it down. The first if statement with the set yVelocity to 0 block in it is their so the cat will not fall through the ground. The next if with the set yVelocity to 15 block in it will function if the cat is on the ground and the up arrow is pressed and will make the cat jump.
Out of that set of ifs the change y by yVelocity will make him fall or rise depending on the velocity variable. And the change yVelocity by -1 is gravity.

Remember that you can change the 15 in the;
http://img406.imageshack.us/img406/8998/picture5a.png
block to make the cat jump higher!

That covers Y Velocity I'll post a tutorial for X Velocity in a little.

    X Velocity:
"xVelocity" will help you make movement along the X Axis seem more realistic.
Start by arranging your stage like this:
http://img149.imageshack.us/img149/3343/stage2.gif
If the picture doesn't load go to this page: http://img149.imageshack.us/my.php?image=stage2.gif
Then in the Cat sprite make the following script:
http://img149.imageshack.us/img149/2018/picture6zrl.png
If the picture doesn't load go to this page: http://img149.imageshack.us/my.php?image=picture6zrl.png
Text of the comment block (if you couldn't read it):
This is the basic script needed to move a sprite along the X Axis with velocity. maxSpeed can be any number you won't depending on how fast you want your sprite to go. The first two if statements will change the xVelocity variable by certain numbers. These numbers can change if you want the sprite to move faster.
The next if-else will make the sprite point in the direction he is moving.
The block: change x by xVelocity will make him move depeding on how fast he is going. The last block is friction and will make the sprite eventually slow to a halt

Now if you combine these two scripts you have perfect jumping and running. I hope this helped answer your questions. If you need any further information post your question and I'll reply as soon as possible.

Last edited by demosthenes (2010-05-09 09:22:44)


I've taken a long hiatus, but I still visit sometimes. Give me some time to answer any messages you post on my projects!

Offline

 

#2 2009-04-21 01:09:36

MyRedNeptune
Community Moderator
Registered: 2007-05-07
Posts: 1000+

Re: Velocity

That's some nice stuff! I'm sure this will help a lot.  smile
Thank you!


http://i52.tinypic.com/5es7t0.png I know what you're thinking! "Neptune! Get rid of those filthy advertisements and give us back the Zarathustra siggy, you horrible person!" Well, don't worry about it, the Zara siggy will be back soon, new and improved! ^^ Meanwhile, just do what the sig tells you to. >.>

Offline

 

#3 2009-04-23 08:23:21

piko_12
Scratcher
Registered: 2009-03-15
Posts: 37

Re: Velocity

demosthenes wrote:

"Velocity" is just the name of a variable, just because it is named velocity doesn't make a difference.
However, if you want to know how to use velocity in one of your games I can help.
    Let's start with "Y Velocity":
Using yVelocity will help if you want to make good jumping scripts for your games.
To start this session of testing arrange the stage like this:
http://img144.imageshack.us/my.php?image=stage.gif
If the image doesn't load go to this link: http://img144.imageshack.us/my.php?image=stage.gif
Then in the Cat sprite make this script:
http://img519.imageshack.us/my.php?imag … re4kef.png
If the image doesn't load go to this link: http://img519.imageshack.us/my.php?image=picture4kef.png
Text of the comment block (if you can't read it):
This is a basic jumping script. We'll start by breaking it down. The first if statement with the set yVelocity to 0 block in it is their so the cat will not fall through the ground. The next if with the set yVelocity to 15 block in it will function if the cat is on the ground and the up arrow is pressed and will make the cat jump.
Out of that set of ifs the change y by yVelocity will make him fall or rise depending on the velocity variable. And the change yVelocity by -1 is gravity.

Remember that you can change the 15 in the;
http://img406.imageshack.us/img406/8998/picture5a.png
block to make the cat jump higher!

That covers Y Velocity I'll post a tutorial for X Velocity in a little.

    X Velocity:
"xVelocity" will help you make movement along the X Axis seem more realistic.
Start by arranging your stage like this:
http://img149.imageshack.us/my.php?image=stage2.gif
If the picture doesn't load go to this page: http://img149.imageshack.us/my.php?image=stage2.gif
Then in the Cat sprite make the following script:
http://img149.imageshack.us/my.php?imag … re6zrl.png
If the picture doesn't load go to this page: http://img149.imageshack.us/my.php?image=picture6zrl.png
Text of the comment block (if you couldn't read it):
This is the basic script needed to move a sprite along the X Axis with velocity. maxSpeed can be any number you won't depending on how fast you want your sprite to go. The first two if statements will change the xVelocity variable by certain numbers. These numbers can change if you want the sprite to move faster.
The next if-else will make the sprite point in the direction he is moving.
The block: change x by xVelocity will make him move depeding on how fast he is going. The last block is friction and will make the sprite eventually slow to a halt

Now if you combine these two scripts you have perfect jumping and running. I hope this helped answer your questions. If you need any further information post your question and I'll reply as soon as possible.

Hey! I finaly did it without the blocks <<  <and> <( <abs( <{ xVelocity }> <<> <{ maxSpeed }> )> >> at X Velocity icon - tutorial. Thank you!

Last edited by piko_12 (2009-04-23 08:24:50)

Offline

 

#4 2009-04-30 18:42:14

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: Velocity

This just explains the code from http://scratch.mit.edu/projects/archmage/72848


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#5 2009-05-01 08:00:46

Scratch4U
Scratcher
Registered: 2009-04-08
Posts: 100+

Re: Velocity

great!


I'm ScratchX

Offline

 

#6 2009-05-01 08:50:22

Llamalover
Scratcher
Registered: 2007-05-18
Posts: 100+

Re: Velocity

If anyone wants to use or look at the scripts here: http://scratch.mit.edu/projects/Llamalover/92546 .

If you use in a project, I'd like it if you credit, but as long as you don't claim it's your own, I don't mind!


Be nice, I'm an old lady  wink

Offline

 

#7 2009-05-06 11:23:26

pokemon_master12
Scratcher
Registered: 2008-09-26
Posts: 100+

Re: Velocity

Brilliant help for my projects! Thanks! It was kind to share your secret of great jumping and running to everyone on the Scratch forums.  smile


My Dragon Egg! http://dragcave.net/image/5YUA.gif
Visit my blog: http://freyasworld.wordpress.com/

Offline

 

#8 2009-07-12 20:53:23

Dudeson
Scratcher
Registered: 2009-05-07
Posts: 25

Re: Velocity

nice! but i dont get it why no one can figure this out by himself?? i also figured everything out by myself... *?

Offline

 

#9 2009-08-03 21:56:04

Grue
Scratcher
Registered: 2009-08-02
Posts: 18

Re: Velocity

Cool. I still don't really understand, I got everything done but I don't understand what everything means.

Offline

 

#10 2009-08-06 04:47:39

awsomegamemaker123
Scratcher
Registered: 2008-11-29
Posts: 2

Re: Velocity

What does the "Abs" do in the Xvelocity tutorial?

Offline

 

#11 2009-08-06 11:37:01

fireball123
Scratcher
Registered: 2008-05-08
Posts: 1000+

Re: Velocity

abs is short for absolute, it means that even if you use it on a negative or positive number it will be negative. I don't think you use it in velocity.


I did it for the Lolz

Offline

 

#12 2009-08-06 18:26:44

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: Velocity

ABS makes numbers positive not negative


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#13 2009-08-12 16:51:26

Adamman715
Scratcher
Registered: 2009-06-13
Posts: 49

Re: Velocity

Ummmmmm, when I press the left arrow key, the cat turns upside down. Why is that???


http://gickr.com/results2/anim_be55add9-67f8-bed4-8ddd-85ad04acb8a5.gif ----------The many faces of Windows! -----------------
http://img215.imageshack.us/img215/5564/ubd2448.png

Offline

 

#14 2009-08-12 17:05:24

henley
Scratcher
Registered: 2008-06-21
Posts: 1000+

Re: Velocity

Adamman715 wrote:

Ummmmmm, when I press the left arrow key, the cat turns upside down. Why is that???

It is because you did not set it to only point left-right. To fix this either make it so that when the left arrow is pressed, it will switch into a costume that is flipped.
or click a button...
http://i27.tinypic.com/ic1x5y.png


"I've worked so hard for you and you give me nothing in return. Do you need help... Or do I?"

Offline

 

#15 2009-08-18 03:52:48

pop676
Scratcher
Registered: 2009-06-23
Posts: 3

Re: Velocity

<when green flag clicked><forever><move( 10<set y to( 6 )steps>

Offline

 

#16 2009-08-18 03:53:48

pop676
Scratcher
Registered: 2009-06-23
Posts: 3

Re: Velocity

<turn cw(  )degrees><go to x sad   )y sad  <point towards( <point towards( <point towards( <go to x sad   )y sad  <point towards( <point towards( <turn cw(  )degrees><turn cw(  )degrees><change{  }by( <set{  }to( <{  }><set{  }to( <play sound[ <play sound[ <play sound[  ]and waits><play sound[  ]and waits><play sound[  ]and waits><play sound[  ]and waits><touching[ <color[  ]is over[ <color[  ]is over[ <color[  ]is over[ <key[  ]pressed?><mouse down?><mouse down?><mouse x><mouse x><mouse y><touching color[

Offline

 

#17 2009-09-07 10:26:05

Mike16112
Scratcher
Registered: 2007-06-09
Posts: 100+

Re: Velocity

Wow... talk about a long script.  hmm

http://img802.mytextgraphics.com/flamewordmaker/2009/09/07/987b6297cfa7e48782e620ed11185fb1.gif
http://img80.imageshack.us/img80/198/mybanner4aa508f1f12ac.png


The programmer has a nap. HOLD OUT! PROGRAMMER!

Offline

 

#18 2009-11-10 03:18:37

rdococ
Scratcher
Registered: 2009-10-11
Posts: 1000+

Re: Velocity

piko_12 wrote:

demosthenes wrote:

"Velocity" is just the name of a variable, just because it is named velocity doesn't make a difference.
However, if you want to know how to use velocity in one of your games I can help.
    Let's start with "Y Velocity":
Using yVelocity will help if you want to make good jumping scripts for your games.
To start this session of testing arrange the stage like this:
http://img144.imageshack.us/my.php?image=stage.gif
If the image doesn't load go to this link: http://img144.imageshack.us/my.php?image=stage.gif
Then in the Cat sprite make this script:
http://img519.imageshack.us/my.php?imag … re4kef.png
If the image doesn't load go to this link: http://img519.imageshack.us/my.php?image=picture4kef.png
Text of the comment block (if you can't read it):
This is a basic jumping script. We'll start by breaking it down. The first if statement with the set yVelocity to 0 block in it is their so the cat will not fall through the ground. The next if with the set yVelocity to 15 block in it will function if the cat is on the ground and the up arrow is pressed and will make the cat jump.
Out of that set of ifs the change y by yVelocity will make him fall or rise depending on the velocity variable. And the change yVelocity by -1 is gravity.

Remember that you can change the 15 in the;
http://img406.imageshack.us/img406/8998/picture5a.png
block to make the cat jump higher!

That covers Y Velocity I'll post a tutorial for X Velocity in a little.

    X Velocity:
"xVelocity" will help you make movement along the X Axis seem more realistic.
Start by arranging your stage like this:
http://img149.imageshack.us/my.php?image=stage2.gif
If the picture doesn't load go to this page: http://img149.imageshack.us/my.php?image=stage2.gif
Then in the Cat sprite make the following script:
http://img149.imageshack.us/my.php?imag … re6zrl.png
If the picture doesn't load go to this page: http://img149.imageshack.us/my.php?image=picture6zrl.png
Text of the comment block (if you couldn't read it):
This is the basic script needed to move a sprite along the X Axis with velocity. maxSpeed can be any number you won't depending on how fast you want your sprite to go. The first two if statements will change the xVelocity variable by certain numbers. These numbers can change if you want the sprite to move faster.
The next if-else will make the sprite point in the direction he is moving.
The block: change x by xVelocity will make him move depeding on how fast he is going. The last block is friction and will make the sprite eventually slow to a halt

Now if you combine these two scripts you have perfect jumping and running. I hope this helped answer your questions. If you need any further information post your question and I'll reply as soon as possible.

Hey! I finaly did it without the blocks <<  <and> <( <abs( <{ xVelocity }> <<> <{ maxSpeed }> )> >> at X Velocity icon - tutorial. Thank you!

I Did it with other blocks! (no varablile)

Offline

 

#19 2009-11-10 03:24:22

rdococ
Scratcher
Registered: 2009-10-11
Posts: 1000+

Re: Velocity

Adamman715 wrote:

Ummmmmm, when I press the left arrow key, the cat turns upside down. Why is that???

Try not using pointing try using X and Y stuff. that way it works!  smile  hope it helps!

________________________________________

If you try to read upsidedown text, you wont belive it!

Offline

 

#21 2010-05-24 15:19:31

donutking
Scratcher
Registered: 2010-04-11
Posts: 11

Re: Velocity

I did everything right for the gravity part, but my sprite won't move! I copied everything EXACTLY!  sad

Offline

 

#22 2010-05-24 15:30:48

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: Velocity

donutking wrote:

I did everything right for the gravity part, but my sprite won't move! I copied everything EXACTLY!  sad

Can you post a picture of your scripts so we can see what's wrong? Or maybe upload it?

Offline

 

#23 2010-05-24 15:31:57

donutking
Scratcher
Registered: 2010-04-11
Posts: 11

Re: Velocity

demosthenes wrote:

"Velocity" is just the name of a variable, just because it is named velocity doesn't make a difference.
However, if you want to know how to use velocity in one of your games I can help.
    Let's start with "Y Velocity":
Using yVelocity will help if you want to make good jumping scripts for your games.
To start this session of testing arrange the stage like this:
http://img144.imageshack.us/img144/416/stage.gif
If the image doesn't load go to this link: http://img144.imageshack.us/my.php?image=stage.gif
Then in the Cat sprite make this script:
http://img213.imageshack.us/ifs/2088/im … re4kef.png
If the image doesn't load go to this link: http://img519.imageshack.us/my.php?image=picture4kef.png
Text of the comment block (if you can't read it):
This is a basic jumping script. We'll start by breaking it down. The first if statement with the set yVelocity to 0 block in it is their so the cat will not fall through the ground. The next if with the set yVelocity to 15 block in it will function if the cat is on the ground and the up arrow is pressed and will make the cat jump.
Out of that set of ifs the change y by yVelocity will make him fall or rise depending on the velocity variable. And the change yVelocity by -1 is gravity.

Remember that you can change the 15 in the;
http://img406.imageshack.us/img406/8998/picture5a.png
block to make the cat jump higher!

That covers Y Velocity I'll post a tutorial for X Velocity in a little.

    X Velocity:
"xVelocity" will help you make movement along the X Axis seem more realistic.
Start by arranging your stage like this:
http://img149.imageshack.us/img149/3343/stage2.gif
If the picture doesn't load go to this page: http://img149.imageshack.us/my.php?image=stage2.gif
Then in the Cat sprite make the following script:
http://img149.imageshack.us/img149/2018/picture6zrl.png
If the picture doesn't load go to this page: http://img149.imageshack.us/my.php?image=picture6zrl.png
Text of the comment block (if you couldn't read it):
This is the basic script needed to move a sprite along the X Axis with velocity. maxSpeed can be any number you won't depending on how fast you want your sprite to go. The first two if statements will change the xVelocity variable by certain numbers. These numbers can change if you want the sprite to move faster.
The next if-else will make the sprite point in the direction he is moving.
The block: change x by xVelocity will make him move depeding on how fast he is going. The last block is friction and will make the sprite eventually slow to a halt

Now if you combine these two scripts you have perfect jumping and running. I hope this helped answer your questions. If you need any further information post your question and I'll reply as soon as possible.

But It keeps falling throught the ground, when I move!

Offline

 

#24 2010-05-24 15:33:42

donutking
Scratcher
Registered: 2010-04-11
Posts: 11

Re: Velocity

coolstuff wrote:

donutking wrote:

I did everything right for the gravity part, but my sprite won't move! I copied everything EXACTLY!  sad

Can you post a picture of your scripts so we can see what's wrong? Or maybe upload it?

Nevermind, but I copied everything right from the gravity part of the first forum comment, and now it keeps falling through the ground when I move!

Offline

 

#25 2010-05-24 15:35:14

donutking
Scratcher
Registered: 2010-04-11
Posts: 11

Re: Velocity

I can't upload projects right now. I can later though. I copied the scripts of the first comment on here, but my sprite keeps falling through the ground...

Offline

 

Board footer