# Some Nice movement

**URL:** <https://forum.kirupa.com/t/some-nice-movement/185567>\
**Category:** Uncategorized\
**Created:** [April 14, 2006, 9:22am UTC](https://forum.kirupa.com/t/some-nice-movement/185567 "2006-04-14T09:22:11Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![ricer](https://avatars.discourse-cdn.com/v4/letter/r/e47774/32.png) [@ricer](https://forum.kirupa.com/u/ricer)\
**Post date:** [April 14, 2006, 9:22am UTC](https://forum.kirupa.com/t/some-nice-movement/185567/1 "2006-04-14T09:22:11Z")

</div>

heya, im creating a new project

a game thats something like this:  
[http://www.armorgames.com/games/armorheroes\_popup.html](http://www.armorgames.com/games/armorheroes_popup.html)

but i need a nice movement for jumping and stuff

the left and right is easy

i made a little script but can someone make it with jumping?

```auto
 
onClipEvent(load){
walkspeed = 0;
}
onClipEvent(enterFrame){
if (Key.isDown(Key.LEFT)) {
_x -= _root.walkspeed
_root.hero.gotoAndPlay("walkleft");
}
if (Key.isDown(Key.LEFT)) {
 _x += _root.walkspeed
_root.hero.gotoAndPlay("walkright");
 }
}

```

thats it 🙂

thnx ^^

---

<div class="post-metadata">

**Author:** ![KIERIOSHIMOTO](https://avatars.discourse-cdn.com/v4/letter/k/c6cbf5/32.png) [@KIERIOSHIMOTO](https://forum.kirupa.com/u/KIERIOSHIMOTO)\
**Post date:** [April 14, 2006, 9:48am UTC](https://forum.kirupa.com/t/some-nice-movement/185567/2 "2006-04-14T09:48:47Z")

</div>

> [@ricer](#):
>
> heya, im creating a new project
> 
> a game thats something like this:  
> [http://www.armorgames.com/games/armorheroes\_popup.html](http://www.armorgames.com/games/armorheroes_popup.html)
> 
> but i need a nice movement for jumping and stuff
> 
> the left and right is easy
> 
> i made a little script but can someone make it with jumping?
> 
> ```
> ActionScript Code:
> [FONT=Courier New][LEFT][COLOR=#0000FF]onClipEvent[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000FF]load[/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000]{[/COLOR]
> 
> ```
> 
> walkspeed = [COLOR=#000080]0[/COLOR];  
> [COLOR=#000000]}[/COLOR]  
> [COLOR=#0000FF]onClipEvent[/COLOR]COLOR=#000000[/COLOR][COLOR=#000000]{[/COLOR]  
> [COLOR=#0000FF]if[/COLOR] COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
> [COLOR=#0000FF]\_x[/COLOR] -= [COLOR=#0000FF]\_root[/COLOR].[COLOR=#000080]walkspeed[/COLOR]  
> [COLOR=#0000FF]\_root[/COLOR].[COLOR=#000080]hero[/COLOR].[COLOR=#0000FF]gotoAndPlay[/COLOR]COLOR=#000000[/COLOR];  
> [COLOR=#000000]}[/COLOR]  
> [COLOR=#0000FF]if[/COLOR] COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
> [COLOR=#0000FF]\_x[/COLOR] += [COLOR=#0000FF]\_root[/COLOR].[COLOR=#000080]walkspeed[/COLOR]  
> [COLOR=#0000FF]\_root[/COLOR].[COLOR=#000080]hero[/COLOR].[COLOR=#0000FF]gotoAndPlay[/COLOR]COLOR=#000000[/COLOR];  
> [COLOR=#000000]}[/COLOR]  
> [COLOR=#000000]}[/COLOR]  
> [/LEFT]  
> [/FONT]
> 
> thats it 🙂
> 
> thnx ^^

Why dont you try Nathan’s platform tutorial [here.](http://n99creations.com/?pID=tutorials&col=Blue&tut=create_platform_game&p=1&l=Flash_MX_04)

---

<div class="post-metadata">

**Author:** ![Joppe](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@Joppe](https://forum.kirupa.com/u/Joppe)\
**Post date:** [April 14, 2006, 10:05am UTC](https://forum.kirupa.com/t/some-nice-movement/185567/3 "2006-04-14T10:05:41Z")

</div>

```auto

onClipEvent (load) {
	walkspeed = 0;
	jump = 6;
	grav = 0;
	jumpin = false;
	fall = true;
}
onClipEvent (enterFrame) {
	trace(jump);
	if (jumpin) {
		jump += 2;
		_y -= jump;
		if (jump>=16) {
			jumpin = false;
		}
	}
	if (!this.hitTest(_root.ground) && !jumpin) {
		fall = true;
		grav++;
	}
	if (fall) {
		_y += grav;
	}
	if (this.hitTest(_root.ground)) {
		fall = false;
		grav = 0;
		jump = 0;
		jumpin = false;
	}
	if (Key.isDown(Key.LEFT)) {
		_x -= walkspeed;
		_root.hero.gotoAndPlay("walkleft");
	}
	if (Key.isDown(Key.LEFT)) {
		_x += walkspeed;
		_root.hero.gotoAndPlay("walkright");
	}
	if (Key.isDown(Key.UP)) {
		if (!fall && !jumpin) {
			jumpin = true;
			fall = false;
		}
	}
}

```

Maybe something like that?

---

<div class="post-metadata">

**Author:** ![ricer](https://avatars.discourse-cdn.com/v4/letter/r/e47774/32.png) [@ricer](https://forum.kirupa.com/u/ricer)\
**Post date:** [April 14, 2006, 11:05am UTC](https://forum.kirupa.com/t/some-nice-movement/185567/4 "2006-04-14T11:05:28Z")

</div>

ai thnx 😃

it works :D:D:D:D ■■■■ ur a genious joppe

(as always) 😛 ur always here to help me 😛 thnx man

if there’s anything i can do for u just ask 😛

---

<div class="post-metadata">

**Author:** ![bombsledder](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@bombsledder](https://forum.kirupa.com/u/bombsledder)\
**Post date:** [April 14, 2006, 2:13pm UTC](https://forum.kirupa.com/t/some-nice-movement/185567/5 "2006-04-14T14:13:45Z")

</div>

😛 i love it people give simple codes and there genious lol

---

<div class="post-metadata">

**Author:** ![nathan99](https://avatars.discourse-cdn.com/v4/letter/n/96bed5/32.png) [@nathan99](https://forum.kirupa.com/u/nathan99)\
**Post date:** [April 14, 2006, 2:17pm UTC](https://forum.kirupa.com/t/some-nice-movement/185567/6 "2006-04-14T14:17:34Z")

</div>

hehe yeah I noticed that… BUT… I let them have a shot at glory… But you know I may just be a good person…

---

<div class="post-metadata">

**Author:** ![bombsledder](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@bombsledder](https://forum.kirupa.com/u/bombsledder)\
**Post date:** [April 14, 2006, 4:25pm UTC](https://forum.kirupa.com/t/some-nice-movement/185567/7 "2006-04-14T16:25:58Z")

</div>

hehe im going to start giving all codes away that people ask for and maybe i could get some recognition =(

---

<div class="post-metadata">

**Author:** ![Joppe](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@Joppe](https://forum.kirupa.com/u/Joppe)\
**Post date:** [April 14, 2006, 4:57pm UTC](https://forum.kirupa.com/t/some-nice-movement/185567/8 "2006-04-14T16:57:49Z")

</div>

why wouldnt you help people?

---

<div class="post-metadata">

**Author:** ![nathan99](https://avatars.discourse-cdn.com/v4/letter/n/96bed5/32.png) [@nathan99](https://forum.kirupa.com/u/nathan99)\
**Post date:** [April 15, 2006, 12:38am UTC](https://forum.kirupa.com/t/some-nice-movement/185567/9 "2006-04-15T00:38:37Z")

</div>

sorry jop…:cantlook:  
here is my version, it’s just very simple and will need tweaking… but useable:  
the game runs off this code

```auto
var moveHorizontalSpeed:Number = 1;
var moveVerticalSpeed:Number = 1;
var space:Number = 5;
var launchInit:Number = -10;
var mapScrollDist:Number = 100;
k.onEnterFrame = function() {
    Key.isDown(Key.SPACE) && !jumping ? (yLaunch=this._y, jumping=jumpSpeed=launchInit) : this._y>=yLaunch && jumpSpeed>0 ? (this._y=yLaunch, jumpSpeed=launchInit, jumping=false) : jumping ? (this._y += jumpSpeed++, this.gotoAndStop("jump")) : null;
    this._y -= yspeed=moveVerticalSpeed*(Key.isDown(Key.UP)-Key.isDown(Key.DOWN));
    Key.isDown(Key.LEFT) && this._x<0+mapScrollDist && g.getBounds(_root).xMin<0+moveHorizontalSpeed ? g._x += moveHorizontalSpeed : Key.isDown(Key.RIGHT) && this._x>Stage.width-mapScrollDist && g.getBounds(_root).xMax>Stage.width-moveHorizontalSpeed ? g._x -= moveHorizontalSpeed : this._x -= speed=moveHorizontalSpeed*(Key.isDown(Key.LEFT)-Key.isDown(Key.RIGHT));
    speed != 0 ? ((this._xscale=speed<0 ? 100 : -100), (!jumping ? this.gotoAndStop("walk") : null)) : yspeed ? (!jumping ? this.gotoAndStop("walk") : null) : (!jumping ? this.gotoAndStop("idle") : null);
    while (this._y<g._y && !g.h.hitTest(this._x, this._y, true) && !jumping) {
        this._y++;
    }
    while (this._y>g._y && !g.h.hitTest(this._x, this._y, true) && !jumping) {
        this._y--;
    }
    while (!g.h.hitTest(this._x-space, this._y, true) && !jumping) {
        this._x++;
    }
    while (!g.h.hitTest(this._x+space, this._y, true) && !jumping) {
        this._x--;
    }
};

```

---

<div class="post-metadata">

**Author:** ![hybrid101](https://avatars.discourse-cdn.com/v4/letter/h/7993a0/32.png) [@hybrid101](https://forum.kirupa.com/u/hybrid101)\
**Post date:** [April 15, 2006, 3:44am UTC](https://forum.kirupa.com/t/some-nice-movement/185567/10 "2006-04-15T03:44:06Z")

</div>

tjat’s pretty complicated for beginners, nathan:)  
nice one joppe:) simple and effective

---

<div class="post-metadata">

**Author:** ![nathan99](https://avatars.discourse-cdn.com/v4/letter/n/96bed5/32.png) [@nathan99](https://forum.kirupa.com/u/nathan99)\
**Post date:** [April 15, 2006, 3:46am UTC](https://forum.kirupa.com/t/some-nice-movement/185567/11 "2006-04-15T03:46:29Z")

</div>

hehe, yeah I thought that… but its simple to me… I guess i forgot how hard it is to grasp as

---

<div class="post-metadata">

**Author:** ![ricer](https://avatars.discourse-cdn.com/v4/letter/r/e47774/32.png) [@ricer](https://forum.kirupa.com/u/ricer)\
**Post date:** [April 15, 2006, 8:13am UTC](https://forum.kirupa.com/t/some-nice-movement/185567/12 "2006-04-15T08:13:40Z")

</div>

thnx nathan 🙂

ok i’ll tell u it 2 then 😛 Nathan ur a genious too man!!! thnx 😃 :p:p:p

---

<div class="post-metadata">

**Author:** ![Joppe](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@Joppe](https://forum.kirupa.com/u/Joppe)\
**Post date:** [April 15, 2006, 11:36am UTC](https://forum.kirupa.com/t/some-nice-movement/185567/13 "2006-04-15T11:36:46Z")

</div>

Actually Nathans the _only_ genious of us too. I learnt how to do the jumping while reading his tutorial. Had no idea before 😉
