# Need help with platforming game

**URL:** https://forum.kirupa.com/t/need-help-with-platforming-game/276569
**Category:** programming
**Created:** [December 1, 2008, 1:42am UTC](https://forum.kirupa.com/t/need-help-with-platforming-game/276569 "2008-12-01T01:42:14Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![scimitar255](https://avatars.discourse-cdn.com/v4/letter/s/848f3c/32.png) [@scimitar255](https://forum.kirupa.com/u/scimitar255)
#### Post date: [December 1, 2008, 1:42am UTC](https://forum.kirupa.com/t/need-help-with-platforming-game/276569/1 "2008-12-01T01:42:14Z")

</div>

Ok, so i’m making a platforming game based off of Shakespeare’s Macbeth (i’m a nerd. shove it.) And I got lots of the coding from this platforming game tutorial:

[http://www.kirupa.com/developer/mx2004/platform\_game.htm](http://www.kirupa.com/developer/mx2004/platform_game.htm)

The problem is when I try to put in another level. What I have is a movie clip on the far end that has the following code on it:

onClipEvent (enterFrame) {  
if (this.hitTest(\_root.macbeth)) {  
\_parent.play();  
}  
}

I have an empty frame between the two parts. The problem is on the second part of the level, all the movie clips have been moved by the previous frame’s coding. You can witness it here:

[http://cid-1ee3d9530713e202.skydrive.live.com/self.aspx/Flash%20Stuff/Macbeth%20lvl%201%20prt%201.swf](http://cid-1ee3d9530713e202.skydrive.live.com/self.aspx/Flash%20Stuff/Macbeth%20lvl%201%20prt%201.swf)

Note: In the third frame of this (i.e. the second level) I just copied everything from the first frame to demonstrate the problem more clearly. I’ve tried changing the instance name, so that did not work.

and here’s the code that is in the player mc (macbeth):

onClipEvent(load) {  
Xpos = this.\_x  
}  
onClipEvent (enterFrame) {  
if (!\_root.ground.hitTest(this.\_x, this.\_y, true) && !jumping) {  
this.\_y += 6;  
}  
speed \*= .85;  
// speed is multiplied by .85  
// the lower the faster is slows  
if (dir == “right” && !\_root.leftblock.hitTest(this.\_x+20, this.\_y, true)) {  
\_root.health.\_x += speed;  
// moves the health, the opposite way to the \_root  
\_root.score.\_x += speed;  
\_root.bkground.\_x += speed;  
// moves the score, the opposite way to the \_root  
this.\_x += speed;  
// moves the char, the opposite way to the \_root  
\_root.\_x -= speed;  
// moves the \_root  
}  
//////////////////////  
////Ammendment 3//  
//////////////////  
if (speed\>0) {  
//if speed is smaller than 0  
dir = “right”;  
// the variable dir is set to right  
} else if (speed\<0) {  
//if speed is greater than 0  
dir = “left”;  
// the var dir is set to left  
}  
if (dir == “left” && !\_root.rightblock.hitTest(this.\_x-20, this.\_y, true)) {  
\_root.health.\_x += speed;  
// moves the health, the opposite way to the \_root  
\_root.score.\_x += speed;  
// moves the score, the opposite way to the \_root  
\_root.bkground.\_x += speed;  
this.\_x += speed;  
// moves the char, the opposite way to the \_root  
\_root.\_x -= speed;  
// moves the \_root  
}  
if (Key.isDown(Key.LEFT)) {  
// if left is pressed  
if (speed\>-maxmove) {  
// if the speed is greater than neg. maxmove  
speed–;  
// speed goes lower  
}  
this.gotoAndStop(“run”);  
// goto and stop the run frame  
this.\_xscale = -50;  
// scale is set to neg. 100  
// this is what rotates ur char  
///////////////////  
///////////////  
} else if (Key.isDown(Key.RIGHT)) {  
// otherwise if right is pressed  
if (speed\<maxmove) {  
// if the speed is smaller than maxmove  
speed++;  
// speed goes up  
}  
this.\_xscale = 50;  
// scale is set to 100  
// this is what rotates ur char  
this.gotoAndStop(“run”);  
// goto and stop the run frame  
}  
}  
onClipEvent (enterFrame) {  
if (Key.isDown(Key.SPACE)) {  
this.\_root(gotoAndPlay(4));  
speed = 0;  
}  
}  
onClipEvent (load) {  
jumping = true;  
jump = 0;  
speed = 0;  
maxmove = 15;  
}  
onClipEvent (enterFrame) {  
if (speed\<1 && speed\>-1 && !attacking) {  
speed = 0;  
}  
if (Key.isDown(Key.UP) && !jumping) {  
// if up is pressed and NOT jumping  
jumping = true;  
// jumping is set true  
}  
if (jumping) {  
// if jumping is true  
this.gotoAndStop(“jump”);  
this.\_y -= jump;  
// Y position is set down jump  
jump -= .5;  
// jump is set down .5  
if (jump\<0) {  
// if jump is smaller than 0  
falling = true;  
// falling is true  
}  
if (jump\<-15) {  
// if jump is smaller than neg. 5  
jump = -15;  
// jump is set to neg 5  
// capping fall speeds prevents falling through grounds  
}  
}  
if (\_root.ground.hitTest(this.\_x, this.\_y, true) && falling) {  
// if hitting X an Y postions with the ground and falling  
jump = 12;  
// jump is set to 9  
jumping = false;  
// jumping is false  
falling = false;  
// falling is false  
}  
}

and here’s where you can view the game:

[http://cid-1ee3d9530713e202.skydrive.live.com/self.aspx/Flash%20Stuff/Macbeth%20lvl%201%20prt%201.swf](http://cid-1ee3d9530713e202.skydrive.live.com/self.aspx/Flash%20Stuff/Macbeth%20lvl%201%20prt%201.swf)

(note on the game: Aarow keys move, up key jumps, space bar attacks. Holding space bar lets you block. Also i know there’s plenty of glitches in the game, but please ignore them… i’ll fix them once i figure out the solution to above problem)

Thanks a lot
