Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void crash(VehicleTurtle vt1, VehicleTurtle vt2) {
- vt1.moveTo(250, 500);
- vt2.moveTo(750, 500);
- vt1.turnRight();
- vt2.turnLeft();
- int x = 0;
- while (x < 1000) {
- if (vt1.getXPos() != vt2.getXPos() && vt2.getXPos() > vt1.getXPos()) {
- Random to100 = new Random();
- int randomInt = (to100.nextInt(70) + 30);
- vt1.forward(randomInt);
- if (vt2.getXPos() < vt1.getXPos()) {
- Random crashX = new Random();
- Random crashY = new Random();
- int craX = (crashX.nextInt(23) + 50);
- int craY = (crashY.nextInt(23) + 50);
- vt1.moveTo(craX, craY);
- int cra2X = (crashX.nextInt(23) + 50);
- int cra2Y = (crashY.nextInt(23) + 50);
- vt2.moveTo(cra2X, cra2Y);
- return;
- }
- vt2.forward(randomInt);
- if (vt2.getXPos() < vt1.getXPos()) {
- Random crashX = new Random();
- Random crashY = new Random();
- int craX = (crashX.nextInt(50) + 25);
- int craY = (crashY.nextInt(50) + 25);
- vt1.moveTo(craX, craY);
- int cra2X = (crashX.nextInt(50) + 25);
- int cra2Y = (crashY.nextInt(50) + 25);
- vt2.moveTo(cra2X, cra2Y);
- return;
- }
- x++;
- } else {
- Random crashX = new Random();
- Random crashY = new Random();
- int craX = (crashX.nextInt(23) + 50);
- int craY = (crashY.nextInt(23) + 50);
- vt1.turnLeft();
- vt1.forward();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement