Advertisement
Guest User

Untitled

a guest
Feb 25th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. var phase=0; // variables permettant la gestion du séquencement du mouvement par incrémentation
  2. var a=200; // coté du carré
  3.  
  4. function r_iniSuivi() { // Function que lance le robot lorsqu'il est prêt
  5. cTimer = setInterval(sequence,500); // création et activavion du timer pour une gestion asynchrone
  6. }
  7. // après sélection
  8. function r_debut() {}
  9. // bouton démarrer
  10. function demarrer() {}
  11. // bouton arrêter
  12. function arreter() {}
  13.  
  14. var choix1=prompt("Quel parcours doit effectuer le robot ? (1 ou 2)");
  15. if(choix1==="1"){
  16. function sequence() {
  17. if (rWd==0&&rWg==0){
  18. switch(phase){
  19. case 0: rX=200; rY=500; rA=1.5*Math.PI;/*-->placement et orientation*/piste(0);r_droit(200,a);break;
  20. case 1: r_rotation(190,90);break;
  21. case 2: r_droit(250,a);break;
  22. case 3: r_rotation(190,90);break;
  23. case 4: r_droit(250,a);break;
  24. case 5: r_rotation(190,90);break;
  25. case 6: r_droit(250,a);break;
  26. case 7: r_rotation(190,135);break;
  27. case 8: r_droit(250,283);break;
  28. case 9: r_rotation(190,-90);break;
  29. case 10: r_droit(250,141);break;
  30. case 11: r_rotation(190,-90);break;
  31. case 12: r_droit(250,141);break;
  32. case 13: r_rotation(190,-90);break;
  33. case 14: r_droit(250,283);break;
  34. case 15: clearInterval(cTimer);
  35. // rangement robot
  36. rX=200+a/2;
  37. rY=200+a/2;
  38. rA=-Math.PI/2;
  39. r_robot();
  40. }
  41. phase++;
  42. }
  43. }
  44. }else if(choix1==="2"){
  45. function sequence() {
  46. if (rWd==0&&rWg==0){
  47. switch(phase){
  48. case 0: rX=50; rY=250; rA=1.5*Math.PI;/*-->placement et orientation*/piste(0);r_droit(200,a);break;
  49. case 1: r_rotation(190,90);break;
  50. case 2: r_cercle(250,200,314);break;
  51. case 3: r_rotation(190,90);break;
  52. case 4: r_droit(250,a);break;
  53. case 5: r_rotation(190,90);break;
  54. case 6: r_cercle(250,200,314);break;
  55. case 7: r_rotation(190,90);break;
  56. case 8: r_droit(250,a);break;
  57. case 9: r_rotation(190,90);break;
  58. case 10: r_cercle(250,200,314);break;
  59. case 11: r_rotation(190,90);break;
  60. case 12: r_droit(250,a);break;
  61. case 13: r_rotation(190,90);break;
  62. case 14: r_cercle(250,200,314);break;
  63. case 15: clearInterval(cTimer);
  64. // rangement robot
  65. rX=200+a/2;
  66. rY=200+a/2;
  67. rA=-Math.PI/2;
  68. r_robot();
  69. }
  70. phase++;
  71. }
  72. }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement