Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. public void teleport(Room room)
  2. {
  3. Random rand = new Random();
  4.  
  5. setX(rand.nextInt(18) + 1); // Radnom X Cordinate + 1 to make sure robby dosent go edge of box
  6. setY(rand.nextInt(18) + 1); // Random Y Cordinate + 1 to make sure robby dosent go edge of box
  7.  
  8. if (!obstacle_ahead(room)) // If no obstcle ahead robby moves
  9. {
  10. move();
  11. }
  12.  
  13. else
  14. {
  15. while (obstacle_ahead(room))
  16. {
  17. setX(rand.nextInt(18) + 1);
  18. setY(rand.nextInt(18) + 1);
  19. move();
  20. }
  21. }
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement