Advertisement
Guest User

crash

a guest
Mar 20th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. public void crash(VehicleTurtle vt1, VehicleTurtle vt2) {
  2. vt1.moveTo(250, 500);
  3. vt2.moveTo(750, 500);
  4. vt1.turnRight();
  5. vt2.turnLeft();
  6. int x = 0;
  7. while (x < 1000) {
  8. if (vt1.getXPos() != vt2.getXPos() && vt2.getXPos() > vt1.getXPos()) {
  9. Random to100 = new Random();
  10. int randomInt = (to100.nextInt(70) + 30);
  11. vt1.forward(randomInt);
  12. if (vt2.getXPos() < vt1.getXPos()) {
  13. Random crashX = new Random();
  14. Random crashY = new Random();
  15. int craX = (crashX.nextInt(23) + 50);
  16. int craY = (crashY.nextInt(23) + 50);
  17. vt1.moveTo(craX, craY);
  18. int cra2X = (crashX.nextInt(23) + 50);
  19. int cra2Y = (crashY.nextInt(23) + 50);
  20. vt2.moveTo(cra2X, cra2Y);
  21.  
  22. return;
  23. }
  24. vt2.forward(randomInt);
  25. if (vt2.getXPos() < vt1.getXPos()) {
  26. Random crashX = new Random();
  27. Random crashY = new Random();
  28. int craX = (crashX.nextInt(50) + 25);
  29. int craY = (crashY.nextInt(50) + 25);
  30. vt1.moveTo(craX, craY);
  31. int cra2X = (crashX.nextInt(50) + 25);
  32. int cra2Y = (crashY.nextInt(50) + 25);
  33. vt2.moveTo(cra2X, cra2Y);
  34. return;
  35. }
  36. x++;
  37. } else {
  38. Random crashX = new Random();
  39. Random crashY = new Random();
  40. int craX = (crashX.nextInt(23) + 50);
  41. int craY = (crashY.nextInt(23) + 50);
  42. vt1.turnLeft();
  43. vt1.forward();
  44. }
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement