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

#1 2009-03-11 17:19:31

SonicKJKH
Scratcher
Registered: 2008-12-06
Posts: 100+

What scratch blocks do you use to make a character jump?

What scratch blocks do you use to make a character jump with the up arrow? I really need help or I can't release a demo of Scratch Adventure!

Offline

 

#2 2009-03-12 12:50:37

daydreamgirl
Scratcher
Registered: 2009-02-20
Posts: 42

Re: What scratch blocks do you use to make a character jump?

<blocks>
<when[ up arrow ]key pressed>
<if> <(<color[ color of character's feet ]is over[ color of platforms/ground)>
<set{ jumping? }to 1
( <repeat(20
<if> <<  <not> <color[ color for character's head]is over[ color of platforms/ground >>
<change y by(some number
<else>
<set{ jumping }to(0
<stop script>

<set{ jumping }to(0
<stop script>

</blocks>

This will make the character jump only if its feet are touching the ground. If its head hits a platform, it will bounce off. (I can't stand games where you can jump onto a platform from directly below it.) The variable jumping is so the character will not fall while it's jumping.

<blocks>
<when green flag clicked>
<forever if><<  <not> <color[ color of feet ]is over[ color of platforms/ground >>
<if> <( <{ jumping }> <=> 0 )>
<change y by(some other number)

</blocks>

This is the gravity script. Change "some number" to make it jump faster. Change "some other number" to make it fall faster.


Hope this helps.


Test Signature

Offline

 

#3 2009-03-12 14:06:59

Targethero
Scratcher
Registered: 2008-09-08
Posts: 1000+

Re: What scratch blocks do you use to make a character jump?

There is a block called "Change y by ____" in the motion section. If you us that block and say Change y by 5 and put a repeat 10 times around it, it will make the character go up then under that part on the same script put a repeat 10 times with a change y by -5 It will go back down.


http://img97.imageshack.us/img97/3981/targethero2.png http://ls.gd/bo

Offline

 

#4 2009-03-12 18:56:49

SonicKJKH
Scratcher
Registered: 2008-12-06
Posts: 100+

Re: What scratch blocks do you use to make a character jump?

Thanks! Now SA V.01 will be released in a few days.

Offline

 

#5 2009-03-12 19:05:59

Spine
Scratcher
Registered: 2009-01-15
Posts: 100

Re: What scratch blocks do you use to make a character jump?

SonicKJKH wrote:

Thanks! Now SA V.01 will be released in a few days.

I have a way on how to do gravity and jumping too...

<when green flag clicked>
<forever>
<if><touching color[ colorofground
<set{grounded  }to( 1
<else>
<set{ grounded }to(0

<when green flag clicked>
<forever if><( grounded <=> 0 )>
<change y by( halfofjumpspeed

<when green flag clicked>
<forever if><<<( grounded <=> 1 )>  <and><key[ up arrow ]pressed?>  >>
<repeat( 10-20
<change y by( double gravity

Hope that helps you!

-Spine

Offline

 

#6 2009-03-12 19:10:55

dsdude10
Scratcher
Registered: 2007-09-22
Posts: 500+

Re: What scratch blocks do you use to make a character jump?

Offline

 

Board footer