# Jumping

**URL:** <https://forum.kirupa.com/t/jumping/113092>\
**Category:** Uncategorized\
**Created:** [June 14, 2004, 11:13pm UTC](https://forum.kirupa.com/t/jumping/113092 "2004-06-14T23:13:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brandon\_L](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/brandon_l/32/583_2.png) [@Brandon\_L](https://forum.kirupa.com/u/Brandon_L)\
**Post date:** [June 14, 2004, 11:13pm UTC](https://forum.kirupa.com/t/jumping/113092/1 "2004-06-14T23:13:52Z")

</div>

[font=Courier New][color=black][font=‘Courier New’]Hey I was wondering if someone would be so kind as to explain the jumping code for a side scroller game because no one seems to want to explain it they just want to have me copy and paste, where’s the fun in that? Someone Please help me I have been messing with it for a couple days now and I can’t figure it out. So I was hoping that one of you fine people could enlighten me.[/font][/color][color=black][font=Arial]\<?xml:namespace prefix = o ns = “urn:schemas-microsoft-com:office:office” /\>\<o:p\>\</o:p\>[/font][/color]

[/font]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 15, 2004, 7:51pm UTC](https://forum.kirupa.com/t/jumping/113092/2 "2004-06-15T19:51:50Z")

</div>

Here Ya Go!

```auto
onClipEvent (load) { 
//When the clip loads
grav_y = 0;
//Gravity on the y axis is zero, this is just a made up variable
jumping = false;
// The mc is not jumping
}
onClipEvent (enterFrame) {
//At any point with the MC
if (Key.isDown(Key.SPACE) && !jumping) {
//If spacebar is pressed and jumping is false so you can't jump numerous times in mid-air
grav_y = 15;
//Set gravity to 15, so he can jump
jumping = true;
//Set Jumping to true
}
if (jumping == true) {
//when jumping is true
grav_y -= 1;
//Starts falling to the ground
if (grav_y<=-7.5) {
grav_y = -7.5;
//If gravity is less than -7.5, gravity equals -7.5 ensures it can't go lower than that
}
this._y -= grav_y;
//Use of the gravity variable to drop the character to the ground
}
if (_root.ground.hitTest(this._x, this._y+45, true)) {
//If the character hits the ground 45 pixels above it
grav_y = 0;

jumping = false;
//Gravity is zero so stop jumping
}
}

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 15, 2004, 9:25pm UTC](https://forum.kirupa.com/t/jumping/113092/3 "2004-06-15T21:25:08Z")

</div>

Thanks a lot guys now i see why this is such a great place.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 16, 2004, 8:57am UTC](https://forum.kirupa.com/t/jumping/113092/4 "2004-06-16T08:57:44Z")

</div>

Cool! I made this place a great place :ne: :snug:
