First of all: its not to submit, just practice for a different game.
Second, heres the script:
onClipEvent (load) {
var speed = 0;
var walk = 4;
var run = 6;
var grav = 0;
var falling = 0;
var jumped = false;
var jumpHeight = 15;
var touchingGround = false;
var scale = _xscale;
}
onClipEvent (enterFrame) {
if (!touchingGround) {
++grav;
this._y += grav;
} else {
grav = 0;
}
if (_root.ground.hitTest(_x, _y, true)) {
touchingGround = true;
} else {
touchingGround = false;
}
if (Key.isDown(37)) {
_x = _x - speed;
this.gotoAndStop(2);
_xscale = -scale;
}
if (Key.isDown(39)) {
_x = _x + speed;
this.gotoAndStop(2);
_xscale = scale;
}
if (Key.isDown(16)) {
speed = run;
} else {
speed = walk;
}
}
onClipEvent (enterFrame) {
if (jumped) {
falling += 0.5;
_y = _y + falling;
if (touchingGround) {
jumped = false;
} else {
if (key.isDown(38)) {
this.gotoAndStop(3);
jumped = true;
falling = -jumpHeight;
}
}
}
if (Key.isDown(38) and Key.isDown(37)) {
this.gotoAndStop(3);
}
if (Key.isDown(38) and Key.isDown(39)) {
this.gotoAndStop(3);
}
if (!Key.isDown(38) and !touchingGround) {
this.gotoAndStop(3);
} else {
if (Key.isDown(38) and !touchingGround) {
this.gotoAndStop(3);
}
}
if (_currentframe == 3 and touchingGround) {
gotoAndStop(1);
}
}
onClipEvent (keyUp) {
gotoAndStop(1);
}
onClipEvent (enterFrame) {
if (this.hitTest(_root.wall)) {
this._x -= speed;
}
if (this.hitTest(_root.wall2)) {
this._x += speed;
}
if (this.hitTest(_root.space)) {
this.gotoAndStop(8);
}
if (this.hitTest(_root.over)) {
_root.gotoAndStop(2);
}
}
}