# Major Platforming Issues!

**URL:** <https://forum.kirupa.com/t/major-platforming-issues/184578>\
**Category:** programming\
**Created:** [April 6, 2006, 12:56am UTC](https://forum.kirupa.com/t/major-platforming-issues/184578 "2006-04-06T00:56:06Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kardin](https://avatars.discourse-cdn.com/v4/letter/k/7993a0/32.png) [@Kardin](https://forum.kirupa.com/u/Kardin)\
**Post date:** [April 6, 2006, 12:56am UTC](https://forum.kirupa.com/t/major-platforming-issues/184578/1 "2006-04-06T00:56:06Z")

</div>

Okay, here’s the deal: I’m making a platformer/RPG. Here’s my main problem: The platforming doesn’t work. I’ve TRIED to program it so that the elf animates but it’s the background that actually moves, so when he jumps, the background moves.

Instead, he freezes in the jumping pose and doesn’t move.

So yah, if you could give me a hand with the coding.

WARNING: Requires Flash 8 ☹

THE FILE: [http://lfs.lfhost.com/clocktowers/ELF.fla](http://lfs.lfhost.com/clocktowers/ELF.fla)

---

<div class="post-metadata">

**Author:** ![woad](https://avatars.discourse-cdn.com/v4/letter/w/34f0e0/32.png) [@woad](https://forum.kirupa.com/u/woad)\
**Post date:** [April 6, 2006, 2:59am UTC](https://forum.kirupa.com/t/major-platforming-issues/184578/2 "2006-04-06T02:59:49Z")

</div>

Umm, have you looked over the internet? And, i’m actually working on a platformer myself: Here’s the jump code:

```
if (jumping) {
	vel_y -= 1;
	if (vel_y&lt;=-10) {
		vel_y = -10;
	}
	this._y -= vel_y;
}
if (Ledge.hitTest(this._x, this._y+this._height/2+15, true)) {
	vel_y = 0;
	jumping = false;
}
```

---

<div class="post-metadata">

**Author:** ![Kardin](https://avatars.discourse-cdn.com/v4/letter/k/7993a0/32.png) [@Kardin](https://forum.kirupa.com/u/Kardin)\
**Post date:** [April 6, 2006, 9:40pm UTC](https://forum.kirupa.com/t/major-platforming-issues/184578/3 "2006-04-06T21:40:43Z")

</div>

Gah, forgot to post the code. \>\_\<

```auto
onClipEvent (load) {
    gravity = 10;
    scale = _xscale;
    walkSpeed = 6;
    maxjump = 6;
}
onClipEvent (enterFrame) {
    if (air == true) {
        _root.loller1.y -= gravity;
        state = 3;
    }
    if (Key.isDown(Key.LEFT) && !_root.leftbound.hitTest(_x, _y, true)) {
        _root.loller1.x += walkSpeed;
        _xscale = -scale;
    }
    if (Key.isDown(Key.RIGHT) && !_root.rightbound.hitTest(_x, _y, true)) {
        _root.loller1.x -= walkSpeed;
        _xscale = scale;
    }
    if (_root.loller1.platforms.hitTest(_x, _y, true)) {
        air = false;
    } else {
        air = true;
    }
    if (Key.isDown(Key.SPACE) && jump == true) {
        _root.loller1.y += jumpSpeed;
    }
    if (air == false) {
        jump = true;
        jumpcount = 0;
        jumpSpeed = 22;
    }
    if (Key.isDown(Key.SPACE)) {
        jumpcount += 1;
    }
    if (jumpcount > maxjump && jumpSpeed > -2) {
        jumpSpeed -= 2;
    }
    if (air == false && !Key.isDown(Key.LEFT) && !Key.isDown(65) && _currentframe < 4 or air == false && !Key.isDown(Key.RIGHT) && !Key.isDown(65) && _currentframe < 4) {
        state = 1;
    }
    if (Key.isDown(Key.LEFT) && air == false && !Key.isDown(65) && _currentframe < 4 or Key.isDown(Key.RIGHT) && air == false && !Key.isDown(65) && _currentframe < 4) {
        state = 2;
    }
    if (!Key.isDown(65)) {
        gotoAndStop(state);
    }
    _root.statetxt = state;
}
onClipEvent (keyUp) {
    if (Key.getCode() == 83) {
        jump = false;
    }
}

```

---

<div class="post-metadata">

**Author:** ![optixburn](https://avatars.discourse-cdn.com/v4/letter/o/82dd89/32.png) [@optixburn](https://forum.kirupa.com/u/optixburn)\
**Post date:** [April 7, 2006, 5:03pm UTC](https://forum.kirupa.com/t/major-platforming-issues/184578/4 "2006-04-07T17:03:39Z")

</div>

try changing the \_root.loller1.x to \_root.loller1.\_x , same with the y’s (to \_y)

looks like you are just moving the property x of loller without moving it on stage (\_x)

maybe this will answer your question?

---

<div class="post-metadata">

**Author:** ![Kardin](https://avatars.discourse-cdn.com/v4/letter/k/7993a0/32.png) [@Kardin](https://forum.kirupa.com/u/Kardin)\
**Post date:** [April 8, 2006, 5:21pm UTC](https://forum.kirupa.com/t/major-platforming-issues/184578/5 "2006-04-08T17:21:41Z")

</div>

Gah, tried that, still not working. Here’s the Flash file, maybe a look at the whole thing would help. \>\_\<

[http://lfs.lfhost.com/clocktowers/ELF.fla](http://lfs.lfhost.com/clocktowers/ELF.fla)

---

<div class="post-metadata">

**Author:** ![Kardin](https://avatars.discourse-cdn.com/v4/letter/k/7993a0/32.png) [@Kardin](https://forum.kirupa.com/u/Kardin)\
**Post date:** [April 9, 2006, 11:35pm UTC](https://forum.kirupa.com/t/major-platforming-issues/184578/6 "2006-04-09T23:35:08Z")

</div>

Alright, I’ve decided to try to use Nathan’s code, but my computer keeps reporting the same syntax error, that being:  
[COLOR=red] **Error** Scene=level 1, layer=Layer 2, frame=1:Line 34: ‘)’ expected  
speed++;

Total ActionScript Errors: 1 Reported Errors: 1[/COLOR]  
Now, the code in question:

```auto
} else if (Key.isDown(Key.RIGHT)) {
if (speed
speed++;
}

```

Now I have a feeling something is missing, so I try:

```auto
} else if (Key.isDown(Key.RIGHT)) {
if (speed<maxmove) {
speed++;
}

```

I get the following error:  
[COLOR=red] **Error** Scene=level 1, layer=Layer 2, frame=1:Line 7: Statement block must be terminated by '}'  
onClipEvent (enterFrame) {

**Error** Scene=level 1, layer=Layer 2, frame=1:Line 62: Syntax error.  
}

Total ActionScript Errors: 2 Reported Errors: 2[/COLOR]

In response to which I try adding a } on the last line.

…And then the entire thing goes to hell. Check the links to see the what I mean. o\_O;

FLA: [http://rapidshare.de/files/17613951/ELF.fla.html](http://rapidshare.de/files/17613951/ELF.fla.html)  
SWF: [http://img127.imageshack.us/my.php?image=elf5cf.swf](http://img127.imageshack.us/my.php?image=elf5cf.swf) (NOTE: The preloader is a bit glitchy, so just right click and press play after it reaches 90% or so.)

---

<div class="post-metadata">

**Author:** ![Nich](https://avatars.discourse-cdn.com/v4/letter/n/e79b87/32.png) [@Nich](https://forum.kirupa.com/u/Nich)\
**Post date:** [April 10, 2006, 12:00am UTC](https://forum.kirupa.com/t/major-platforming-issues/184578/7 "2006-04-10T00:00:15Z")

</div>

> [@Kardin](#):
>
> Alright, I’ve decided to try to use Nathan’s code, but my computer keeps reporting the same syntax error, that being:  
> [COLOR=red] **Error** Scene=level 1, layer=Layer 2, frame=1:Line 34: ‘)’ expected  
> speed++;
> 
> Total ActionScript Errors: 1 Reported Errors: 1[/COLOR]  
> Now, the code in question:
> 
> ```auto
> } else if (Key.isDown(Key.RIGHT)) {
> if (speed
> speed++;
> }
> 
> ```
> 
> Now I have a feeling something is missing, so I try:
> 
> ```auto
> } else if (Key.isDown(Key.RIGHT)) {
> if (speed<maxmove) {
> speed++;
> }
> 
> ```
> 
> I get the following error:  
> [COLOR=red] **Error** Scene=level 1, layer=Layer 2, frame=1:Line 7: Statement block must be terminated by ‘}’  
> onClipEvent (enterFrame) {
> 
> **Error** Scene=level 1, layer=Layer 2, frame=1:Line 62: Syntax error.  
> }
> 
> Total ActionScript Errors: 2 Reported Errors: 2[/COLOR]
> 
> In response to which I try adding a } on the last line.
> 
> …And then the entire thing goes to hell. Check the links to see the what I mean. o\_O;
> 
> FLA: [http://rapidshare.de/files/17613951/ELF.fla.html](http://rapidshare.de/files/17613951/ELF.fla.html)  
> SWF: [http://img127.imageshack.us/my.php?image=elf5cf.swf](http://img127.imageshack.us/my.php?image=elf5cf.swf) (NOTE: The preloader is a bit glitchy, so just right click and press play after it reaches 90% or so.)

Try this. Not sure exactly what I did but it seems to work.  
[http://rapidshare.de/files/17615020/ELF.fla.html](http://rapidshare.de/files/17615020/ELF.fla.html)

---

<div class="post-metadata">

**Author:** ![Kardin](https://avatars.discourse-cdn.com/v4/letter/k/7993a0/32.png) [@Kardin](https://forum.kirupa.com/u/Kardin)\
**Post date:** [April 10, 2006, 1:51am UTC](https://forum.kirupa.com/t/major-platforming-issues/184578/8 "2006-04-10T01:51:58Z")

</div>

Geh, it still has some glitches. He only faces right, and only falls when he jumps. \>\_\<

---

<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 10, 2006, 5:30am UTC](https://forum.kirupa.com/t/major-platforming-issues/184578/9 "2006-04-10T05:30:25Z")

</div>

what I would do, is, make 2 mcs, the characer instance name, c, and the ground, instance name, gr;

then I woukld modify this code;

```auto
sh = 20, c.ysp=4
c.onEnterFrame = function() {
 Key.isDown(Key.UP) && !jumping ? (jumping=true, jump=-20) : !gr.hitTest(this._x, this._y+1, true) && !jumping ? this._y+=this.ysp++ : null;
 jumping ? ((!Key.isDown(Key.UP) && jump<=-3 ? jump *= .5 : null), (jump<=-3 ? this._y += (jump *= .85) : jump>-3 ? this._y += (jump++) : null)) : null;
 Key.isDown(Key.LEFT) && !gr.hitTest(this.getBounds(_root).xMin, this._y-sh, true) ? this._x -= 3 : Key.isDown(Key.RIGHT) && !gr.hitTest(this.getBounds(_root).xMax, this._y-sh, true) ? this._x += 3 : null;
 while (gr.hitTest(this._x, this._y, true)) {
  this._y--, this.ysp = 4, jump=jumping=false;
 }
};

```

---

<div class="post-metadata">

**Author:** ![Kardin](https://avatars.discourse-cdn.com/v4/letter/k/7993a0/32.png) [@Kardin](https://forum.kirupa.com/u/Kardin)\
**Post date:** [April 10, 2006, 11:48pm UTC](https://forum.kirupa.com/t/major-platforming-issues/184578/10 "2006-04-10T23:48:33Z")

</div>

See, thing is I’m very new to actionscript, and wouldn’t know what to change. My main problem with that code is that my game is intented to be a sidescroller. \>\_\<

---

<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 11, 2006, 12:08am UTC](https://forum.kirupa.com/t/major-platforming-issues/184578/11 "2006-04-11T00:08:57Z")

</div>

how exactly do you want it?

---

<div class="post-metadata">

**Author:** ![Kardin](https://avatars.discourse-cdn.com/v4/letter/k/7993a0/32.png) [@Kardin](https://forum.kirupa.com/u/Kardin)\
**Post date:** [April 12, 2006, 12:44am UTC](https://forum.kirupa.com/t/major-platforming-issues/184578/12 "2006-04-12T00:44:46Z")

</div>

> [@nathan99](#):
>
> how exactly do you want it?

So that the screen follows the character across the level, and that the character us always centered on the screen.

---

<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 13, 2006, 8:11am UTC](https://forum.kirupa.com/t/major-platforming-issues/184578/13 "2006-04-13T08:11:02Z")

</div>

```auto
sh = 20, c.ysp=4
c.onEnterFrame = function() {
 Key.isDown(Key.UP) && !jumping ? (jumping=true, jump=-20) : !gr.hitTest(this._x, this._y+1, true) && !jumping ? this._y+=this.ysp++ : null;
 jumping ? ((!Key.isDown(Key.UP) && jump<=-3 ? jump *= .5 : null), (jump<=-3 ? this._y += (jump *= .85) : jump>-3 ? this._y += (jump++) : null)) : null;
 Key.isDown(Key.LEFT) && !gr.hitTest(this.getBounds(_root).xMin, this._y-sh, true) ? gr._x += 3 : Key.isDown(Key.RIGHT) && !gr.hitTest(this.getBounds(_root).xMax, this._y-sh, true) ? gr._x -= 3 : null;
 while (gr.hitTest(this._x, this._y, true)) {
  this._y--, this.ysp = 4, jump=jumping=false;
 }
};

```
