Advertisement
Guest User

Untitled

a guest
Feb 28th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. static int[][] g = {{0,-1},{1,0},{1,0},{1,0},{1,0},{0,-1},{0,-1},{0,-1},{0,-1},{0,-1},{0,-1},{1,0},{0,1},{0,1},{0,1},{0,1},{0,1},{0,1},{0,1},{-1,0},{-1,0},{-1,0},{-1,0},{-1,0}};
  2.  
  3.  
  4. public void move(){
  5. Random rg = new Random();
  6. int d = rg.nextInt(2);
  7.  
  8. if(d == 0){//segue o percurso normal
  9. setCoordinates(x+g[a][0], y+g[a][1]);
  10. a++;
  11. }
  12. else if(d == 1){//inverte o percurso
  13. a--;
  14. setCoordinates(x-g[a][0],y-g[a][1]);
  15. }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement