In my project, I've got the jumping down so that the sprite doesn't fall through, and the running part as well. So how would I make that work for another platform that the sprite would jump up on to? Or better yet, jump through it and then when the sprite lands on the new platform it would stop.
I just need the script for this, that would be very helpful. I don't really have time to look through 100 pages of forums, so if there is already a post could you please send me a link to it?
Offline
I hope this helped!
Offline
Well actually or the jump script I'm using the custom variable y velocity:
<when green flag clicked>
<set{ y velocity }to( 0
<forever>
<if><touching[ Sprite 2
<set{ y velocity }to( 0
<if><key[ up arrow ]pressed?>
<set{ y velocity }to( 15
<change y by( <{ y velocity }>
<change{ y velocity }by( -1
Something like that. But yeah, that's what I'm using to jump. Would it be much different using that script?
Last edited by WhiteStone (2010-06-04 09:51:52)
Offline
I was considering using velocity and gravity, but I decided to keep it simple. You would have to make a few adaptations, but the basic script and idea would be the same. I'm sure you can figure it out.
By the way, I would suggest using
[blocks]
<set{ y velocity }to( (( <{ y veloicty }> <*> 0.9 ))
[/blocks]
instead of
[blocks]
<change{ velocity }by( -1
[/blocks]
It may not make things easier in this case, but it will help later on.
Offline
http://scratch.mit.edu/projects/Subh2/1099515
I could not take a screenshot so I uploaded the project
Offline
shadow_7283 wrote:
By the way, I would suggest using
[blocks]
<set{ y velocity }to( (( <{ y veloicty }> <*> 0.9 ))
[/blocks]
instead of
[blocks]
<change{ velocity }by( -1
[/blocks]
Problem with that is that it doesn't make the sprite fall, it'll only continually decrease the y velocity so it will continue to go up at a decreasing interval.
But actually, I figured out how to do it on my own.
<when green flag clicked>
<forever>
<if><< <touching[ Platform 1 <and> <( <{ y velocity }> <<> 1 )> >>
<set{ y velocity }to( 0
<if><key[ up arrow ]pressed?>
<set{ y velocity }to( 15
So, the sprite can only be on the platform if it is falling, which means it can jump through them, and it is able to jump off of it. Since the jump is specific to each platform, it makes it much easier to manipulate all the variables whenever needed.
And I managed to fix one of my own glitches, yes I am very proud of myself.
Offline