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

#1 2011-01-01 15:47:28

SnowBall94
New Scratcher
Registered: 2010-12-03
Posts: 9

Jumping doesn't work completely :(

I found some jumping scripts from various forums and scratch projects but each one of them always makes my sprite go through the platform instead of going on top of it like it does in the examples. If anyone could help me that would be great  smile

I used two basic types of coding since I couldn't understand most of the advanced variable jumping scripts:

1:
<when[ up ]key pressed>
<forever if><key[ up arrow ]pressed?>
<set{ Gravity }to( 12)
<change y by( 10)
<repeat until><touching[ Platform ]
<change{ Gravity }by( -1)
<change y by( Gravity)

2:
<when green flag clicked>
<set{ Jump }to( 0 )
<forever>
<if><<  <( Jump <=> 0 )><and> <<  <not> <touching[ Platform >> >>
<repeat( 10
<change y by( -10
<wait( 0.03 )secsc>

<when[ up arrow ]key pressed>
<set{ Jump }to( 1
<if><touching[ Platform
<repeat( 10
<change y by( 10
<wait( 0.03 )secsc>
<repeat( 10
<if><<  <not> <touching[ Platform >>
<change y by( -10
<wait( 0.03 )secsc>
<set{ Jump }to( 0

Offline

 

#2 2011-01-01 16:04:37

StrykerV
New Scratcher
Registered: 2010-06-15
Posts: 51

Re: Jumping doesn't work completely :(

Have you tried using velocity?
If not, try this


99.9999% Crazy, 0.0001% Hamburgeh Makeh  smile

Offline

 

#3 2011-01-01 16:16:51

SnowBall94
New Scratcher
Registered: 2010-12-03
Posts: 9

Re: Jumping doesn't work completely :(

Thanks I'll try it out and hopefully it will work  big_smile

Offline

 

#4 2011-01-01 16:27:59

hello12345678910
Scratcher
Registered: 2009-07-11
Posts: 100+

Re: Jumping doesn't work completely :(

Try StrykerV's velocity suggestion. or...


{when GF clicked}
   forever
if <key up arrow pressed>
repeat 10
change Y by 10
end
else
if <touching ground>
change Y by 10
end
if <not<touching ground>>
change Y by -10
end


http://tinyurl.com/8yt32o9 http://tinyurl.com/6tgwp5r || Fish = F+I+S+H = 6+9+19+8 = 42<<The answer to Life, the Universe and Everything

Offline

 

#5 2011-01-01 16:38:40

SnowBall94
New Scratcher
Registered: 2010-12-03
Posts: 9

Re: Jumping doesn't work completely :(

hello12345678910 wrote:

Try StrykerV's velocity suggestion. or...


{when GF clicked}
   forever
if <key up arrow pressed>
repeat 10
change Y by 10
end
else
if <touching ground>
change Y by 10
end
if <not<touching ground>>
change Y by -10
end

I tried doing this script but it makes the sprite jittery but thanks for the script  smile

Offline

 

#6 2011-01-01 16:42:56

hello12345678910
Scratcher
Registered: 2009-07-11
Posts: 100+

Re: Jumping doesn't work completely :(

SnowBall94 wrote:

hello12345678910 wrote:

Try StrykerV's velocity suggestion. or...


{when GF clicked}
   forever
if <key up arrow pressed>
repeat 10
change Y by 10
end
else
if <touching ground>
change Y by 10
end
if <not<touching ground>>
change Y by -10
end

I tried doing this script but it makes the sprite jittery but thanks for the script  smile

he will not jitter in presentation mode or on the site, just in the editor


http://tinyurl.com/8yt32o9 http://tinyurl.com/6tgwp5r || Fish = F+I+S+H = 6+9+19+8 = 42<<The answer to Life, the Universe and Everything

Offline

 

#7 2011-01-01 16:49:33

SnowBall94
New Scratcher
Registered: 2010-12-03
Posts: 9

Re: Jumping doesn't work completely :(

hello12345678910 wrote:

SnowBall94 wrote:

hello12345678910 wrote:

Try StrykerV's velocity suggestion. or...


{when GF clicked}
   forever
if <key up arrow pressed>
repeat 10
change Y by 10
end
else
if <touching ground>
change Y by 10
end
if <not<touching ground>>
change Y by -10
end

I tried doing this script but it makes the sprite jittery but thanks for the script  smile

he will not jitter in presentation mode or on the site, just in the editor

It worked thanks  smile  but is there another coding that I could put in so even if you continously press the up button he doesn't go any higher than I want him too?

Offline

 

#8 2011-01-01 16:56:16

SnowBall94
New Scratcher
Registered: 2010-12-03
Posts: 9

Re: Jumping doesn't work completely :(

SnowBall94 wrote:

hello12345678910 wrote:

SnowBall94 wrote:

I tried doing this script but it makes the sprite jittery but thanks for the script  smile

he will not jitter in presentation mode or on the site, just in the editor

It worked thanks  smile  but is there another coding that I could put in so even if you continously press the up button he doesn't go any higher than I want him too?

For some reason now its jittery in both editor and presentation  hmm  ....i didn't change any of the codings

Offline

 

#9 2011-01-01 17:02:49

SnowBall94
New Scratcher
Registered: 2010-12-03
Posts: 9

Re: Jumping doesn't work completely :(

StrykerV wrote:

Have you tried using velocity?
If not, try this

When I tried yours, it worked better than my old one, but it sometimes get stuck if there are multiple ground on top of one another like this

                                        ------------

                          --------------------------

----------------------------------------------------

any way to fix this?

Offline

 

#10 2011-01-01 18:09:36

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

Re: Jumping doesn't work completely :(

SnowBall94 wrote:

StrykerV wrote:

Have you tried using velocity?
If not, try this

When I tried yours, it worked better than my old one, but it sometimes get stuck if there are multiple ground on top of one another like this

                                        ------------

                          --------------------------

----------------------------------------------------

any way to fix this?

The velocity tutorial I made that StrykerV linked you to only covers basic jumping. You'd have to try more advanced things such as collision testing if you want to prevent the sprite from getting stuck.

Here is a relatively simple project with collision testing you might want to look at: http://scratch.mit.edu/projects/archmage/101212

If you have questions about the script in that project, just ask us here  smile


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

 

#11 2011-01-02 12:36:59

SnowBall94
New Scratcher
Registered: 2010-12-03
Posts: 9

Re: Jumping doesn't work completely :(

demosthenes wrote:

SnowBall94 wrote:

StrykerV wrote:

Have you tried using velocity?
If not, try this

When I tried yours, it worked better than my old one, but it sometimes get stuck if there are multiple ground on top of one another like this

                                        ------------

                          --------------------------

----------------------------------------------------

any way to fix this?

The velocity tutorial I made that StrykerV linked you to only covers basic jumping. You'd have to try more advanced things such as collision testing if you want to prevent the sprite from getting stuck.

Here is a relatively simple project with collision testing you might want to look at: http://scratch.mit.edu/projects/archmage/101212

If you have questions about the script in that project, just ask us here  smile

Thanks for the link but I think that script may be too advanced for me.

Offline

 

Board footer