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

#1 2010-02-10 13:58:46

Greatjj4
Scratcher
Registered: 2010-02-10
Posts: 1

how do you make a sprite jump and float down like mario?

How do you make a sprite jump up and then glide to the ground again like mario?

Offline

 

#2 2010-02-11 19:06:51

shadow_7283
Scratcher
Registered: 2007-11-07
Posts: 1000+

Re: how do you make a sprite jump and float down like mario?

Hmm... we want to make this as realistic as possible right? Here is what I did for one of my games:

1. Create a variable called Gravity and another called Up Arrow Pressed?
2. You also need some sort of background or color that acts as the ground for the character. I will use the # symbol to signify this
3. Use these scripts:

When Green Flag Clicked
forever
   if <key up arrow pressed>
      change y by -2
      if touching #
          if <not <Up Arrow Pressed *= 1>
          set gravity to 7
          set Up Arrow Pressed* to 1
          change y by gravity
      change y by 2
   change y by gravity
   if <not <touching #>
   change Gravity by -0.3

*(the variable)

I could go into MUCH MORE complicated movement scripts, but I think this answers your question.  big_smile  Scratch On!

Offline

 

#3 2010-02-11 19:08:51

RHY3756547
Scratcher
Registered: 2009-08-15
Posts: 1000+

Re: how do you make a sprite jump and float down like mario?

shadow_7283 wrote:

Hmm... we want to make this as realistic as possible right? Here is what I did for one of my games:

1. Create a variable called Gravity and another called Up Arrow Pressed?
2. You also need some sort of background or color that acts as the ground for the character. I will use the # symbol to signify this
3. Use these scripts:

When Green Flag Clicked
forever
   if <key up arrow pressed>
      change y by -2
      if touching #
          if <not <Up Arrow Pressed *= 1>
          set gravity to 7
          set Up Arrow Pressed* to 1
          change y by gravity
      change y by 2
   change y by gravity
   if <not <touching #>
   change Gravity by -0.3

*(the variable)

I could go into MUCH MORE complicated movement scripts, but I think this answers your question.  big_smile  Scratch On!

Leading onto the more complicated scripts would be like the ones found in my Perfect Platformer Base:

http://scratch.mit.edu/projects/RHY3756547/845502

It has some helpful comments, slope detection etc.

Offline

 

#4 2010-02-24 20:12:00

acester
Scratcher
Registered: 2009-08-29
Posts: 3

Re: how do you make a sprite jump and float down like mario?

I tried doing the script shadow_7283 did, but it only made me go down. No, I didn't go back up. May somebody make a different script?


Check out my latests (absolutely awesome) projects here: http://scratch.mit.edu/users/acester  big_smile

Offline

 

#5 2010-02-24 22:04:46

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: how do you make a sprite jump and float down like mario?

acester wrote:

I tried doing the script shadow_7283 did, but it only made me go down. No, I didn't go back up. May somebody make a different script?

Hm...

I looks like it should work. I'll make mine:
Again, # is the ground.

Code:

|when green flag clicked|
[forever]
  change y by (-1)
  if <touching #>
    set Gravity to (0)
      if <key [up arrow] pressed?>
        set Gravity to 10
      [end if]
  [else]
    change Gravity by (-1)
  [end if]
  change y by ((Gravity + 1))
[end forever]

Tell me if this works.

Last edited by MathWizz (2010-02-24 22:05:53)


http://block.site90.net/scratch.mit/text.php?size=30&amp;text=%20A%20signature!&amp;color=333333

Offline

 

#6 2010-02-24 23:10:13

shadow_7283
Scratcher
Registered: 2007-11-07
Posts: 1000+

Re: how do you make a sprite jump and float down like mario?

acester wrote:

I tried doing the script shadow_7283 did, but it only made me go down. No, I didn't go back up. May somebody make a different script?

Could you post your project online? That's the best way for us to help.

Offline

 

#7 2010-03-01 17:14:12

ThePCKid
Scratcher
Registered: 2009-09-16
Posts: 1000+

Re: how do you make a sprite jump and float down like mario?

I hope that this will work for you
P.S. I added scripts for the left and right arrow keys.
--------------------------------------------------------------------------
Background that I used:
http://i48.tinypic.com/eziumw.gif
Scripts that I used:
http://i50.tinypic.com/2zsmk44.gif

Offline

 

#8 2010-03-01 17:33:44

shadow_7283
Scratcher
Registered: 2007-11-07
Posts: 1000+

Re: how do you make a sprite jump and float down like mario?

ThePCKid wrote:

I hope that this will work for you
P.S. I added scripts for the left and right arrow keys.

It's a nice example, but it doesn't have very realistic jumping like Mario does.

Offline

 

#9 2010-03-01 18:52:45

howlcall
Scratcher
Registered: 2010-02-23
Posts: 24

Re: how do you make a sprite jump and float down like mario?

I had a really long if statement... I didn't know how to make the ground though... but here's what I have:

[blocks]
<if><key[ space ]pressed?>
<set{ hieght  }to( 0
<repeat( 18<change{ hieght }by( 1
<change{ y }by( hieght
<if><key[ left arrow ]pressed?>
<change x by( -10
<if><key[ right aroow ]pressed?>
<change x by( 10
[/blocks]

So what I was doing was to go right basicly... but you could go either direction now. just press space with this which changes the variable of hieght and then press left or right arrow keys to move either way. tell me if it doesn't work.

Offline

 

#10 2010-03-01 20:17:12

shadow_7283
Scratcher
Registered: 2007-11-07
Posts: 1000+

Re: how do you make a sprite jump and float down like mario?

It wouldn't work because it wouldn't go back down... and the gravity is opposite.

I don't mean to sound obnoxious but... just stick with my method.

Last edited by shadow_7283 (2010-03-01 20:17:54)

Offline

 

#11 2010-03-01 21:04:40

howlcall
Scratcher
Registered: 2010-02-23
Posts: 24

Re: how do you make a sprite jump and float down like mario?

It worked for my project.

Offline

 

#12 2010-03-01 21:09:15

shadow_7283
Scratcher
Registered: 2007-11-07
Posts: 1000+

Re: how do you make a sprite jump and float down like mario?

howlcall wrote:

[blocks]
<if><key[ space ]pressed?>
<set{ hieght  }to( 0
<repeat( 18<change{ hieght }by( 1
<change{ y }by( hieght
<if><key[ left arrow ]pressed?>
<change x by( -10
<if><key[ right aroow ]pressed?>
<change x by( 10
[/blocks]
---------------------------------------------------------------------------
It worked for my project.

Think about it. What you are saying is repeat 18 times change [height] by 1, change y by height. So at the end of the script the character will move eighteen spaces up (with the y movement increasing EACH REPEAT). What about going back down?

Offline

 

#13 2010-03-01 22:18:48

superstikfa
Scratcher
Registered: 2009-11-23
Posts: 10

Re: how do you make a sprite jump and float down like mario?

Easy,when green flag clicked forever if key up arrow key pressed and touching color black reapeat 10 change y by 10. big_smile

Offline

 

#14 2010-03-01 22:25:20

howlcall
Scratcher
Registered: 2010-02-23
Posts: 24

Re: how do you make a sprite jump and float down like mario?

I think I forgot to copy somthing important... because it does go back down... and you have a good point... 0_0 I forgot to copy somthing... let me get back to you.

Offline

 

#15 2010-03-01 22:28:09

howlcall
Scratcher
Registered: 2010-02-23
Posts: 24

Re: how do you make a sprite jump and float down like mario?

woops, my bad forgot that I copied that and did it again accept backwards to go down... sorry, you're right. but it does work after that!  wink

Offline

 

#16 2010-03-02 11:35:18

markyparky56
Scratcher
Registered: 2008-03-20
Posts: 1000+

Re: how do you make a sprite jump and float down like mario?

I use this script, is not exactly floating back, but you can change the gravity to vary the speed that the person comes back down.

http://img194.imageshack.us/img194/5642/jumpscript.gif


http://j.mp/jgVnTq
Check out my game engine development site: NewDawn I'm a Level 171 Scratcher.I am http://bit.ly/nkvLNT

Offline

 

#17 2010-03-10 15:27:33

markyparky56
Scratcher
Registered: 2008-03-20
Posts: 1000+

Re: how do you make a sprite jump and float down like mario?

haniyamout1 wrote:

<set{gems  }to(0
<say[ Hi gorge ]for( 3 )secs>
<say[ do you want som gems? ]for( 2 )secs>
<broadcast[next person
<when I receive[next person
<say[ yes please ]for( 1 )secs>
<change{gems }by(1

please dont spam.


http://j.mp/jgVnTq
Check out my game engine development site: NewDawn I'm a Level 171 Scratcher.I am http://bit.ly/nkvLNT

Offline

 

Board footer