It's not really broken, but it looks really weird.
Here's an example of my engine: http://img496.images..age=untitled14rx.swf
The good thing is that the ball doesn't fall through the ground AND that the ground is with slopes. But the jumping looks extremely un-reallistic.
Here's my code:
onClipEvent(enterFrame){
while(_root.ground.hitTest(this._x,this._y
,true)){
this._y --;
jump = false;
}
if(!_root.ground.hitTest(this._x,this._y,t
rue) && !jump){
fall = true;
}
if(fall == true){
_y += 5;
}
if(Key.isDown(Key.SPACE)){
jumping = true;
}else{
jumping = false;
}
if(!jump && jumping){
this._y -= vel;
vel = vel + gra / 2;
gra --;
}
if(gra < 1){
gra = 8;
jumping = false;
jump = true;
vel = 0;
fall = true;
}
trace("Velocity: " + vel + " Gravity: " + gra);
}
And here are the traced variables in the output window, I took them when the player was jumping. The problem is probably that one frame after the velocity is 17.5, it goes to 0 which makes it look like it hit teh roof. It should go like 0,2,5,10,15,13,9,5,2 or something like that...
Velocity: 0 Gravity: 8
Velocity: 4 Gravity: 7
Velocity: 7.5 Gravity: 6
Velocity: 10.5 Gravity: 5
Velocity: 13 Gravity: 4
Velocity: 15 Gravity: 3
Velocity: 16.5 Gravity: 2
Velocity: 17.5 Gravity: 1
Velocity: 0 Gravity: 8
Velocity: 0 Gravity: 8
Velocity: 0 Gravity: 8