# Can't make my character jump

**URL:** <https://forum.kirupa.com/t/cant-make-my-character-jump/207034>\
**Category:** flash\
**Created:** [November 14, 2006, 5:31am UTC](https://forum.kirupa.com/t/cant-make-my-character-jump/207034 "2006-11-14T05:31:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![red\_rockstar\_15](https://avatars.discourse-cdn.com/v4/letter/r/f6c823/32.png) [@red\_rockstar\_15](https://forum.kirupa.com/u/red_rockstar_15)\
**Post date:** [November 14, 2006, 5:31am UTC](https://forum.kirupa.com/t/cant-make-my-character-jump/207034/1 "2006-11-14T05:31:18Z")

</div>

I am creating a game in flash using spirte sheets of megaman and I have a problem setting up script to make him jump. I am able to have megaman run side to side and also shoot but I can not get him to jump. Here is a sample of my code:

var hspeed = 0;  
var vspeed = 0;  
var i = 0;  
var d = 1;  
stance = false;  
jumpspeed = -10  
gravity = 2  
//var ob = \_root.megaman;  
//var keyPressed = false;  
onEnterFrame = function(){  
new\_y = current\_y - jumpspeed  
jumpspeed = jumpspeed + gravity

\_x = \_x + hspeed  
\_y = \_y + vspeed

//trace(\_y);

if (Key.isDown(Key.RIGHT) ) {  
hspeed = 5;  
gotoAndPlay(“sr”);  
shoot\_right.gotoAndPlay(“s3”);  
d = 1;  
}

if (Key.isDown(Key.LEFT) ) {  
hspeed = -5;  
gotoAndPlay(“sl”);  
shoot\_left.gotoAndPlay(“l3”);  
d = -1;  
}

if (!Key.isDown(Key.LEFT) and !Key.isDown(Key.RIGHT)) {  
hspeed = 0;  
gotoAndStop(“init”);  
shoot\_right.gotoAndStop(“stance”);  
}  
if (Key.isDown(Key.SPACE) ){  
if (!Key.isDown(Key.LEFT) and (!Key.isDown(Key.RIGHT))){  
gotoAndPlay(“ss”);  
}  
//gotoAndPlay(“ss”);  
\_parent.fire();  
}

/\*if (!Key.isDown(Key.UP) and !stance and (vspeed \< 0)) {  
vspeed = 0;  
}  
\_x+=hspeed;  
\_y+=vspeed;

if (\_y \< 400) {  
vspeed++;  
} else {  
vspeed = 0;  
stance = true;  
}  
if (Key.isDown(Key.UP) and stance) {  
stance = false;  
vspeed = -13;  
gotoAndPlay(“jr”)  
//jump\_right.gotoAndPlay(“js”)  
}

if (Key.isDown(Key.UP)){  
vspeed = -50;  
gotoAndPlay(“jr”)  
jump\_right.gotoAndPlay(“js”)

} else {  
vspeed++;  
vspeed = 0;  
}\*/

I have been trying to do two different methods but they do not seem to work. Any suggestions would be nice.
