Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var phase=0; // variables permettant la gestion du séquencement du mouvement par incrémentation
- var a=200; // coté du carré
- function r_iniSuivi() { // Function que lance le robot lorsqu'il est prêt
- cTimer = setInterval(sequence,500); // création et activavion du timer pour une gestion asynchrone
- }
- // après sélection
- function r_debut() {}
- // bouton démarrer
- function demarrer() {}
- // bouton arrêter
- function arreter() {}
- var choix1=prompt("Quel parcours doit effectuer le robot ? (1 ou 2)");
- if(choix1==="1"){
- function sequence() {
- if (rWd==0&&rWg==0){
- switch(phase){
- case 0: rX=200; rY=500; rA=1.5*Math.PI;/*-->placement et orientation*/piste(0);r_droit(200,a);break;
- case 1: r_rotation(190,90);break;
- case 2: r_droit(250,a);break;
- case 3: r_rotation(190,90);break;
- case 4: r_droit(250,a);break;
- case 5: r_rotation(190,90);break;
- case 6: r_droit(250,a);break;
- case 7: r_rotation(190,135);break;
- case 8: r_droit(250,283);break;
- case 9: r_rotation(190,-90);break;
- case 10: r_droit(250,141);break;
- case 11: r_rotation(190,-90);break;
- case 12: r_droit(250,141);break;
- case 13: r_rotation(190,-90);break;
- case 14: r_droit(250,283);break;
- case 15: clearInterval(cTimer);
- // rangement robot
- rX=200+a/2;
- rY=200+a/2;
- rA=-Math.PI/2;
- r_robot();
- }
- phase++;
- }
- }
- }else if(choix1==="2"){
- function sequence() {
- if (rWd==0&&rWg==0){
- switch(phase){
- case 0: rX=50; rY=250; rA=1.5*Math.PI;/*-->placement et orientation*/piste(0);r_droit(200,a);break;
- case 1: r_rotation(190,90);break;
- case 2: r_cercle(250,200,314);break;
- case 3: r_rotation(190,90);break;
- case 4: r_droit(250,a);break;
- case 5: r_rotation(190,90);break;
- case 6: r_cercle(250,200,314);break;
- case 7: r_rotation(190,90);break;
- case 8: r_droit(250,a);break;
- case 9: r_rotation(190,90);break;
- case 10: r_cercle(250,200,314);break;
- case 11: r_rotation(190,90);break;
- case 12: r_droit(250,a);break;
- case 13: r_rotation(190,90);break;
- case 14: r_cercle(250,200,314);break;
- case 15: clearInterval(cTimer);
- // rangement robot
- rX=200+a/2;
- rY=200+a/2;
- rA=-Math.PI/2;
- r_robot();
- }
- phase++;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement