- // déclaration des variables
- onClipEvent (load) {
- x = _x;
- y = _y;
- gravite = 0;
- elan = 0;
- elany = 0;
- }
- onClipEvent (enterFrame) {
- if (_root.termine==0) {
- x = _x;
- y = _y;
- dirKeyDown=0;
- // mouvement droite - gauche
- // et le cas ou rien
- if (Key.isDown(Key.RIGHT)) {
- _root.direction=1;
- if ((_root.accessoire==0) and (_root.chapeau==0)) {
- _root.tim.gotoAndStop(2); // marche à dte
- } else if ((_root.accessoire==1) and (_root.pouf==0)) {
- _root.tim.gotoAndStop(5); // vole à dte
- } else if (_root.chapeau==1) {
- _root.tim.gotoAndStop(13);
- }
- if (elan>-8) {
- elan -= 2;
- }
- dirKeyDown=1;
- } else if (Key.isDown(Key.LEFT)) {
- _root.direction=0;
- if ((_root.accessoire==0) and (_root.chapeau==0)) {
- _root.tim.gotoAndStop(3); // marche à gche
- } else if ((_root.accessoire==1) and (_root.pouf==0)) {
- _root.tim.gotoAndStop(6); // vole à gche
- } else if (_root.chapeau==1) {
- _root.tim.gotoAndStop(14);
- }
- if (elan<8) {
- elan += 2;
- }
- dirKeyDown=1;
- } else if (Key.isDown(Key.SPACE)) {
- if (_root.pouf==1) {
- elany = -20;
- _root.tim.gotoAndStop(9);
- } else {
- if (elany<0) {
- elany += 2;
- }
- }
- }
-
- if (Key.isDown(Key.DOWN)) {
- if (_root.accessoire==1) {
- if (elany<8) {
- elany += 2;
- }
- }
- } else if (Key.isDown(Key.UP)) {
- if (_root.accessoire==1) {
- if (elany>-8) {
- elany -= 2;
- }
- }
- }
- if (_y<-20) elany=10;
- if ( ! dirKeyDown and ! Key.isDown(Key.SPACE)) {
- if (_root.direction==1) {
- if ((_root.accessoire==0) and (_root.chapeau==0)) {
- _root.tim.gotoAndStop(1);
- } else if (_root.accessoire==1) {
- _root.tim.gotoAndStop(7);
- } else if (_root.chapeau==1) {
- _root.tim.gotoAndStop(12);
- }
- } else if (_root.direction==0) {
- if ((_root.accessoire==0) and (_root.chapeau==0)) {
- _root.tim.gotoAndStop(4);
- } else if (_root.accessoire==1) {
- _root.tim.gotoAndStop(7);
- } else if (_root.chapeau==1) {
- _root.tim.gotoAndStop(15);
- }
- }
- if (elan<0) {
- elan = elan+1;
- } else if (elan>0) {
- elan = elan-1;
- }
- if (elany<0) {
- elany = elany+1;
- } else if (elany>0) {
- elany = elany-1;
- }
- }
-
- _root.sol._x = _root.sol._x+elan;
- _root.fond._x = _root.fond._x+elan/1.2;
- _root.fond2._x = _root.fond2._x+elan/1.2;
- _root.fond3._x = _root.fond3._x+elan/1.2;
- _root.fond4._x = _root.fond4._x+elan/1.2;
- _root.fond5._x = _root.fond5._x+elan/1.2;
- _root.fond6._x = _root.fond6._x+elan/1.2;
- _root.fond7._x = _root.fond7._x+elan/1.2;
- _root.fond8._x = _root.fond8._x+elan/1.2;
- _root.fond9._x = _root.fond9._x+elan/1.2;
- _root.fond10._x = _root.fond10._x+elan/1.2;
- _root.fond11._x = _root.fond11._x+elan/1.2;
- _root.fond12._x = _root.fond12._x+elan/1.2;
- _root.fond13._x = _root.fond13._x+elan/1.2;
- _root.tim._y = _root.tim._y+elany;
-
- // si le bonhomme touche le sol
- // -> hitTest : compare les coordonnees des MC
- // et true indique qu'on prend l'objet et pas les contours
- if (_root.sol.hitTest(x, y, true)) {
- if (_root.accessoire==0) {
- gravite = 0;
- // permet de revenir en haut de l'objet directement
- // sauf si c'est trop haut (limite de 20 pixels ici)
- while (_root.sol.hitTest(x, y-1, true)) {
- y--;
- if (y<=_y-20) {
- if (_root.sol.hitTest(x+10, y, true)) {
- elan=-10;
- }
- if (_root.sol.hitTest(x-10, y, true)) {
- elan=10;
- }
- _root.sol._x -= 2*elan;
- elan = -elan;
- break;
- }
- }
- _y=y;
- } else if (_root.accessoire==1 && _root.sol.hitTest(x, y-1, true)) {
- _root.chapeau=0;
- _root.accessoire=0;
- }
- } else {
- if (gravite<15) {
- gravite = gravite+1;
- }
- }
- if ( (_root.sol.hitTest(x, y+1, true)) and not (_root.sol.hitTest(x, y-1, true))) {
- if (Key.isDown(Key.UP)) {
- if (_root.chapeau==0) {
- gravite = -12;
- } else if (_root.chapeau==1) {
- if (_y>180) {
- gravite = -18;
- } else gravite = -12;
- }
- }
- }
- if (_root.accessoire==0) {
- _y = _y+gravite;
- }
- // retourne en haut en cas de chute
- if (_y>500) {
- _root.tim.gotoAndStop(11);
- _root.txtfin._visible=1;
- _root.termine=1;
- _y=-120;
- }
- }
- }
// déclaration des variables
onClipEvent (load) {
x = _x;
y = _y;
gravite = 0;
elan = 0;
elany = 0;
}
onClipEvent (enterFrame) {
if (_root.termine==0) {
x = _x;
y = _y;
dirKeyDown=0;
// mouvement droite - gauche
// et le cas ou rien
if (Key.isDown(Key.RIGHT)) {
_root.direction=1;
if ((_root.accessoire==0) and (_root.chapeau==0)) {
_root.tim.gotoAndStop(2); // marche à dte
} else if ((_root.accessoire==1) and (_root.pouf==0)) {
_root.tim.gotoAndStop(5); // vole à dte
} else if (_root.chapeau==1) {
_root.tim.gotoAndStop(13);
}
if (elan>-8) {
elan -= 2;
}
dirKeyDown=1;
} else if (Key.isDown(Key.LEFT)) {
_root.direction=0;
if ((_root.accessoire==0) and (_root.chapeau==0)) {
_root.tim.gotoAndStop(3); // marche à gche
} else if ((_root.accessoire==1) and (_root.pouf==0)) {
_root.tim.gotoAndStop(6); // vole à gche
} else if (_root.chapeau==1) {
_root.tim.gotoAndStop(14);
}
if (elan<8) {
elan += 2;
}
dirKeyDown=1;
} else if (Key.isDown(Key.SPACE)) {
if (_root.pouf==1) {
elany = -20;
_root.tim.gotoAndStop(9);
} else {
if (elany<0) {
elany += 2;
}
}
}
if (Key.isDown(Key.DOWN)) {
if (_root.accessoire==1) {
if (elany<8) {
elany += 2;
}
}
} else if (Key.isDown(Key.UP)) {
if (_root.accessoire==1) {
if (elany>-8) {
elany -= 2;
}
}
}
if (_y<-20) elany=10;
if ( ! dirKeyDown and ! Key.isDown(Key.SPACE)) {
if (_root.direction==1) {
if ((_root.accessoire==0) and (_root.chapeau==0)) {
_root.tim.gotoAndStop(1);
} else if (_root.accessoire==1) {
_root.tim.gotoAndStop(7);
} else if (_root.chapeau==1) {
_root.tim.gotoAndStop(12);
}
} else if (_root.direction==0) {
if ((_root.accessoire==0) and (_root.chapeau==0)) {
_root.tim.gotoAndStop(4);
} else if (_root.accessoire==1) {
_root.tim.gotoAndStop(7);
} else if (_root.chapeau==1) {
_root.tim.gotoAndStop(15);
}
}
if (elan<0) {
elan = elan+1;
} else if (elan>0) {
elan = elan-1;
}
if (elany<0) {
elany = elany+1;
} else if (elany>0) {
elany = elany-1;
}
}
_root.sol._x = _root.sol._x+elan;
_root.fond._x = _root.fond._x+elan/1.2;
_root.fond2._x = _root.fond2._x+elan/1.2;
_root.fond3._x = _root.fond3._x+elan/1.2;
_root.fond4._x = _root.fond4._x+elan/1.2;
_root.fond5._x = _root.fond5._x+elan/1.2;
_root.fond6._x = _root.fond6._x+elan/1.2;
_root.fond7._x = _root.fond7._x+elan/1.2;
_root.fond8._x = _root.fond8._x+elan/1.2;
_root.fond9._x = _root.fond9._x+elan/1.2;
_root.fond10._x = _root.fond10._x+elan/1.2;
_root.fond11._x = _root.fond11._x+elan/1.2;
_root.fond12._x = _root.fond12._x+elan/1.2;
_root.fond13._x = _root.fond13._x+elan/1.2;
_root.tim._y = _root.tim._y+elany;
// si le bonhomme touche le sol
// -> hitTest : compare les coordonnees des MC
// et true indique qu'on prend l'objet et pas les contours
if (_root.sol.hitTest(x, y, true)) {
if (_root.accessoire==0) {
gravite = 0;
// permet de revenir en haut de l'objet directement
// sauf si c'est trop haut (limite de 20 pixels ici)
while (_root.sol.hitTest(x, y-1, true)) {
y--;
if (y<=_y-20) {
if (_root.sol.hitTest(x+10, y, true)) {
elan=-10;
}
if (_root.sol.hitTest(x-10, y, true)) {
elan=10;
}
_root.sol._x -= 2*elan;
elan = -elan;
break;
}
}
_y=y;
} else if (_root.accessoire==1 && _root.sol.hitTest(x, y-1, true)) {
_root.chapeau=0;
_root.accessoire=0;
}
} else {
if (gravite<15) {
gravite = gravite+1;
}
}
if ( (_root.sol.hitTest(x, y+1, true)) and not (_root.sol.hitTest(x, y-1, true))) {
if (Key.isDown(Key.UP)) {
if (_root.chapeau==0) {
gravite = -12;
} else if (_root.chapeau==1) {
if (_y>180) {
gravite = -18;
} else gravite = -12;
}
}
}
if (_root.accessoire==0) {
_y = _y+gravite;
}
// retourne en haut en cas de chute
if (_y>500) {
_root.tim.gotoAndStop(11);
_root.txtfin._visible=1;
_root.termine=1;
_y=-120;
}
}
}