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

#1 2011-11-20 07:13:21

mayukhnair
New Scratcher
Registered: 2011-11-20
Posts: 2

How to make my character jump?

Hey there.....I am a newbie and am developing a fighting game on scratch. The trouble is, my character doesn't jump. Can anybody help me out please?????
Please suggest the simplest way to execute this command.
The guy with the best answer gets his name in my game's credits!  smile   big_smile
Quick!!!!Help me!!!!!
Thanks a lot!

Offline

 

#2 2011-11-20 09:42:36

LFOB
Scratcher
Registered: 2010-06-11
Posts: 90

Re: How to make my character jump?

<when[ up arrow ]key pressed>
<repeat( 20
<change y by( 2
<end>
<wait( 0.3 )secs>
<repeat( 20
<change y by( -2
<end>

Last edited by LFOB (2011-11-20 09:42:57)


http://scratch.mit.edu/static/projects/LFOB/2413118_med.png  http://scratch.mit.edu/static/projects/LFOB/2255829_med.png

Offline

 

#3 2011-11-20 11:09:22

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: How to make my character jump?

It depends on what you want it to take into account.  For instance, LFOB's script doesn't use gravity or let you jump to a ground of different elevation.  Do you want a script that includes those?  Do you want a script that detects ceilings?  Please be more specific.


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#4 2011-11-20 11:31:29

RedRocker227
Scratcher
Registered: 2011-10-26
Posts: 1000+

Re: How to make my character jump?

Try looking at this. It even says how to bounce as well.


Why

Offline

 

#5 2011-11-23 07:42:44

mayukhnair
New Scratcher
Registered: 2011-11-20
Posts: 2

Re: How to make my character jump?

RedRocker227 wrote:

Try looking at this. It even says how to bounce as well.

Hey RedRocker227, thanks a billion for the tutorial, but still all it does is go up and stay there, though I copied your steps exactly. I would really like you to program the jumps. Can you please write a script for making the fighters jump on this post, using the blocks just like LFOB did? The game is multiplayer and one fighter jumps with W while the other jumps with up arrow key. Please help me out pal.

Hey LFOB, your script works but the jumps don't look real. Can you write the script again so that the sprite goes up and comes down without stopping in the air for a second? Thanks!

Offline

 

#6 2011-11-23 10:36:59

flyby65
Scratcher
Registered: 2011-11-06
Posts: 4

Re: How to make my character jump?

try using this:
<when green flag clicked>
<forever>
<if><key[ up arrow ]pressed?>
<set{ yvelocity }to( 5)
<change y by( 5)
<repeat until><touching color[ color of platforms ]
<change y by( <{ yvelocity }>
<change{ yvelocity }by( -.2)
<set{ yvelocity }to( 0)
<repeat until><<  <not>  >><touching color[ color of platforms ]
<change y by( 3 )
<if><touching color[ color of platforms ]
<change y by( 0)
<else>
<change y by( -3)

Offline

 

#7 2011-11-23 10:40:10

flyby65
Scratcher
Registered: 2011-11-06
Posts: 4

Re: How to make my character jump?

you can also serch the project jump/gravity script demo to find the same script.

Offline

 

#8 2011-11-23 10:43:37

RedRocker227
Scratcher
Registered: 2011-10-26
Posts: 1000+

Re: How to make my character jump?

mayukhnair wrote:

RedRocker227 wrote:

Try looking at this. It even says how to bounce as well.

Hey RedRocker227, thanks a billion for the tutorial, but still all it does is go up and stay there, though I copied your steps exactly. I would really like you to program the jumps. Can you please write a script for making the fighters jump on this post, using the blocks just like LFOB did? The game is multiplayer and one fighter jumps with W while the other jumps with up arrow key. Please help me out pal.

So you're saying it goes up, but doesn't come back down? Have you made sure you've got the bit like this: 'change 'y velocity' by -1' in the 'else' bit of the 'if touching colour [colour of ground]' ?


Why

Offline

 

#9 2011-11-27 08:12:57

itchyback
New Scratcher
Registered: 2011-11-27
Posts: 3

Re: How to make my character jump?

I found this useful off youtube

http://s1096.photobucket.com/albums/g332/rhea_lity/?action=view&current=script.png

Offline

 

#10 2011-11-27 10:58:40

raffalevy
Scratcher
Registered: 2008-09-09
Posts: 1

Re: How to make my character jump?

[blocks]
<when[ space ]key pressed>
<glide(1 )secs to x sad <x position> )y sad  (( <y position> <+> 30 )))
<glide(1 )secs to x sad <x position> )y sad  (( <y position> <-> 30 )))
[/blocks]

Last edited by raffalevy (2011-11-27 11:00:01)

Offline

 

#11 2011-11-27 11:04:32

codes321
Scratcher
Registered: 2011-10-19
Posts: 78

Re: How to make my character jump?

Well, first you need to change the Y. So, I would recommend that you change the Y by probably 30-60. Then, you need to wait 1 or 0.5 seconds, basically how long you want it to be. Then, change Y by -30, or the number you use to change the Y the first time.

[blocks]<when[space key pressed> ] OR <when[ up arrow ]key pressed><change y by(#, preferably 30-60)<wait( 1 )secsc><change y by( -#, what you used to change the first y) [/blocks]

Have fun with that game!  smile

Last edited by codes321 (2011-11-27 11:06:25)


Check out my projects!  roll   roll   roll   roll   roll   roll   roll   roll   roll   roll   roll

Offline

 

#12 2011-11-29 17:26:32

itchyback
New Scratcher
Registered: 2011-11-27
Posts: 3

Re: How to make my character jump?

Sorry the image link I posted earlier doesn't work - just add this into a html viewer (http://www.tizag.com/htmlPractice.php)

<a href="http://s1096.photobucket.com/albums/g332/rhea_lity/?action=view&amp;current=script.png" target="_blank"><img src="http://i1096.photobucket.com/albums/g332/rhea_lity/script.png" border="0" alt="Photobucket"></a>

it shows how to make your character jump and move side to side?

Offline

 

#13 2011-12-02 07:53:25

itchyback
New Scratcher
Registered: 2011-11-27
Posts: 3

Re: How to make my character jump?

http://tinypic.com/r/10of94x/5

Offline

 

#14 2011-12-02 10:37:32

RedRocker227
Scratcher
Registered: 2011-10-26
Posts: 1000+

Re: How to make my character jump?

itchyback wrote:

http://tinypic.com/r/10of94x/5

Fixed!
Just put this:

Code:

[url=http://www.example.com]Text goes here[/url]

And also, the 'Change x velocity by 2' is WAY too high. It needs to be something like 0.3.  smile

Last edited by RedRocker227 (2011-12-02 10:38:34)


Why

Offline

 

#15 2011-12-03 15:25:41

LewisZapata-Lee
New Scratcher
Registered: 2011-11-30
Posts: 45

Re: How to make my character jump?

jumping can be accomplished by using a variable.  some scratchers call it "gravity", but I normally call it "y velocity" unless there is a more advanced script in which this is already a variable.  I normally use this script:
when green flag clicked
|set [y velocity] to [0]|
|forever|
|chance y by (y velocity)|
|change [y velocity] by [-1]|
|if <touching colour [{floor colour}]>|
|set [y velocity] to [0]|
|if <key [{jump button}] pressed?>|
|set [y velocity] to [{how high you want to jump}]|

for this to fully work, the second "if" block should be inside the first.

Offline

 

#16 2011-12-04 08:52:30

LewisZapata-Lee
New Scratcher
Registered: 2011-11-30
Posts: 45

Re: How to make my character jump?

sorry, my finger slipped when I wrote "change" one time, and I only noticed this after submitting the post.  sorry if this confused you.

Offline

 

#17 2011-12-04 11:26:00

RedRocker227
Scratcher
Registered: 2011-10-26
Posts: 1000+

Re: How to make my character jump?

Try looking at this tutorial  smile


Why

Offline

 

#18 2012-01-29 07:32:22

vectrex
New Scratcher
Registered: 2012-01-22
Posts: 4

Re: How to make my character jump?

i was wondering, how do you hake a charecter jump AND move at the same time?

Offline

 

#19 2012-01-29 09:42:57

RedRocker227
Scratcher
Registered: 2011-10-26
Posts: 1000+

Re: How to make my character jump?

vectrex wrote:

i was wondering, how do you hake a charecter jump AND move at the same time?

Ugh, necroposters...


Why

Offline

 

Board footer