my game i am making is proving to be dificult. the charactor in it keeps on falling through the "ground" even though it still works and all. it just goes down further than it should. here is the code for my charactor
onClipEvent (load) {
var ground:MovieClip = _root.ground;
var grav:Number = 4;
var gravity:Number = 4;
var speed:Number = 9;
var maxJump:Number = -25;
var doubleJump:Boolean = false;
var touchingGround:Boolean = true;
var fight:Boolean = true;
}
onClipEvent (enterFrame) {
_y += grav;
grav += gravity;
while (ground.hitTest(_x, _y, true)) {
_y -= gravity;
grav = 0;
}if (Key.isDown(Key.UP) && touchingGround) {
grav = maxJump;
mySound=new Sound();
mySound.attachSound("jumping");
mySound.start();
}if (ground.hitTest(_x+5, _y+5, true)) {
touchingGround = true;
} else {
touchingGround = false;
}if(fight == false){
if(Key.isDown(Key.LEFT) && fight != true){
this._x -= speed;
this.gotoAndStop("left");
}else if(Key.isDown(Key.RIGHT) && fight != true){
this._x += speed;
this.gotoAndStop("right");
}else if(Key.isDown(Key.DOWN)){
this.gotoAndStop("crouch");
}else{
this.gotoAndStop("idle");
}
}
if(Key.isDown(Key.UP) && Key.isDown(Key.RIGHT)){
this.gotoAndStop("right jump");
this._x+= speed;
}else if(Key.isDown(Key.UP) && Key.isDown(Key.LEFT)){
this.gotoAndStop("left jump");
this._x-=speed;
}if(Key.isDown(Key.SPACE) && Key.isDown(Key.RIGHT)){
this.gotoAndPlay("stomp right");
fight = true;
}else if(Key.isDown(Key.SPACE) && Key.isDown(Key.LEFT)){
this.gotoAndPlay("stomp left");
fight = true;
}if(this._currentframe == 1){ fight = false;
}if (ground.hitTest(_x+(_width/2), _y-(_height/2), true)) {
_x += speed;
}if (ground.hitTest(_x-(_width/2), _y-(_height/2), true)) {
_x -= speed;
}if (ground.hitTest(_x, _y-(height), true)) {
grav =0;
}
}
could someone pleas tell me what i am doing wrong?
its actionscript 2 also..