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

#1 2007-06-18 11:58:20

corbjop
Scratcher
Registered: 2007-06-13
Posts: 14

how to make a character jump and come back down

im making a mario like game and i cant figure out how to make them jump and come back down without pressing anything extra please help if you can

Offline

 

#2 2007-06-18 12:45:07

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

Re: how to make a character jump and come back down

Just do this

when key up pressed
repeat 30
change y by 3
repeat 30
change y by -3



That should make your sprite jump properly.


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

 

#3 2007-06-18 13:32:11

corbjop
Scratcher
Registered: 2007-06-13
Posts: 14

Re: how to make a character jump and come back down

thanks

Offline

 

#4 2007-06-18 14:00:31

corbjop
Scratcher
Registered: 2007-06-13
Posts: 14

Re: how to make a character jump and come back down

theres one more thing how do you make them stand on somthing in the air without falling

Offline

 

#5 2007-06-18 14:57:28

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

Re: how to make a character jump and come back down

Try this

first make a platform sprite

{make character land on platform}

when key up pressed
repeat 30
change y by 3
repeat 30
if not touching platform
change y by -3


This will make it so he will not fall if touching a platform. However the sprite cannot fall down because he doesn't have gravity codes in him.


If you want gravity codes go to get new sprite from file then go into things and then select gravity ball.

If you are new to scratch and not experienced in programming it might be too confusing for you.

some examples of games that use gravity movement are
http://scratch.mit.edu/projects/archmage/9397
http://scratch.mit.edu/projects/archmage/12293




or if you want really basic gravity try this:

{put this on player sprite for basic gravity}
when flag clicked
forever
if jump =0 and not touching platform
change y by -3


{however for this to work we must also add the jump variable to the jump code}

when key up pressed
set jump to 1
repeat 30
change y by 3
repeat 30
if not touching platform
change y by -3
{add the set jump after the repeat block NOT inside it}
set jump to 0


Try it out and if you want I can program a demo of what I just talked about in this post.

Last edited by archmage (2007-06-18 18:00:28)


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

 

#6 2007-06-18 15:21:58

corbjop
Scratcher
Registered: 2007-06-13
Posts: 14

Re: how to make a character jump and come back down

thank you alot thats really helpful

Offline

 

#7 2007-06-18 15:30:27

corbjop
Scratcher
Registered: 2007-06-13
Posts: 14

Re: how to make a character jump and come back down

i tried that and it just made the sprite float in the air and not on the block

Offline

 

#8 2007-06-18 15:33:46

corbjop
Scratcher
Registered: 2007-06-13
Posts: 14

Re: how to make a character jump and come back down

when it sais if jump = 0 how do i get jump

Offline

 

#9 2007-06-18 17:59:41

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

Re: how to make a character jump and come back down

To make a variable go to variable's tab and create variable. And make the variable name jump. When you are done post your project and ill fix the bugs.

Also I forgot to add the forever in the basic gravity code I added it now.

Last edited by archmage (2007-06-18 18:01:18)


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

 

#10 2007-06-18 18:16:26

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

Re: how to make a character jump and come back down

I made this http://scratch.mit.edu/projects/archmage/14600

It is a demonstration of what I was talking about feel download to download the project and look at the code that makes it tick.


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

 

#11 2007-06-22 09:49:00

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

Re: how to make a character jump and come back down

try using a variable so a smooth jump is allowed.
set 'jump' to 10
repeat 21
[change y by jump,
change jump by -1
wait 0.01 seconds]


http://scratch.mit.edu/projects/bigB/260981 Draw to Text
http://scratch.mit.edu/projects/bigB/181829 3D Stunt Flyer

Offline

 

Board footer