# Jumping and sidescrollers

**URL:** https://forum.kirupa.com/t/jumping-and-sidescrollers/216911
**Category:** programming
**Created:** [February 21, 2007, 4:25pm UTC](https://forum.kirupa.com/t/jumping-and-sidescrollers/216911 "2007-02-21T16:25:32Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![zeldafreak](https://avatars.discourse-cdn.com/v4/letter/z/74df32/32.png) [@zeldafreak](https://forum.kirupa.com/u/zeldafreak)
#### Post date: [February 21, 2007, 4:25pm UTC](https://forum.kirupa.com/t/jumping-and-sidescrollers/216911/1 "2007-02-21T16:25:32Z")

</div>

Hey guys, I have been working on a sidescroller system and I have the left and right movements done, but I am at a loss as to how I can have him jump and have the gravity kick in. Here is the current code.

```auto
onClipEvent (load) {
    fallspeed = 8;
    platforms = 1;
    speed = 5;
    falldec = 1.95;
}
onClipEvent (enterFrame) {
    fallspeed += falldec;
    this._y += fallspeed;
    for (i=1; i<=platforms; i++) {
        ground = _root["g"+i];
        if (this.hitTest(ground)) {
            this._y -= fallspeed;
        }
    }
    if (Key.isDown(Key.SPACE) && jumping != true) {
        jumping = true;
    }
    if (jumping == true) {
    //What to put here?
    }
    
    if(Key.isDown(Key.LEFT)){
        this._x -= speed;
        this._xscale =-100;
        this.gotoAndStop("run");
        //_root._x += speed;
    }
    else if(Key.isDown(Key.RIGHT)){
        this._x += speed;
        this._xscale =100;
        this.gotoAndStop("run");
        //_root._x -= speed;
    }
    else{
        this.gotoAndStop("idle");
}
}

```

The comments about the Root x position are simply to move the stage later on, not sure about them currently though.  
I can upload the Fla later If need be, any help is appreciated. Thanks guys 😃
