# Jet pack game problems

**URL:** https://forum.kirupa.com/t/jet-pack-game-problems/289465
**Category:** Uncategorized
**Created:** [May 31, 2009, 12:57am UTC](https://forum.kirupa.com/t/jet-pack-game-problems/289465 "2009-05-31T00:57:01Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![lan0011](https://avatars.discourse-cdn.com/v4/letter/l/df705f/32.png) [@lan0011](https://forum.kirupa.com/u/lan0011)
#### Post date: [May 31, 2009, 12:57am UTC](https://forum.kirupa.com/t/jet-pack-game-problems/289465/1 "2009-05-31T00:57:01Z")

</div>

hi i am trying to make a platform game where u walk around and kill things. i’ve made my char walk and i have found a code to make him fly except that i only want him to flay when he collects touches a certain object.  
please help.  
code or  
fla would be most appreciated.  
🙂

this is the code for my char mc to make him move.  
onClipEvent (enterFrame) {  
if(Key.isDown(Key.RIGHT)){  
this.\_x += 12;  
this.gotoAndStop (“right”);  
}  
else if(Key.isDown(Key.LEFT)){  
this.\_x -= 12;  
this.gotoAndStop (“left”);  
}  
else if(Key.isDown(Key.DOWN)){  
this.\_x -= 0;  
this.gotoAndStop (“down”);

}  
}  
and this is the code that goes on the frame to make him fly.

yspeed = 0;  
xspeed = 0;  
gravity = 0.2;  
rotationspeed = 0;  
power = 1;  
friction = 0.9;  
fly.onEnterFrame = function() {  
yspeed += gravity;  
xspeed _= friction;  
this.\_x += xspeed;  
rotationspeed = friction;  
this.\_rotation = 0+rotationspeed;  
if (this.\_y\<=400-this.\_height/2) {  
this.\_y += yspeed;  
if (Key.isDown(37)) {  
xspeed -= power;  
rotationspeed += powerxspeed/2;  
} else if (Key.isDown(39)) {  
xspeed += power;  
rotationspeed += power_xspeed/2;  
}  
} else {  
xspeed \*= friction;  
yspeed = 0;  
this.\_y = 400-this.\_height/2;  
}  
if (Key.isDown(38)) {  
yspeed -= power;  
}  
if (yspeed\<0) {  
yspeed \*= friction;  
}  
};

thanx
