Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.88 KB | None | 0 0
  1. public Point nextLocation()
  2. {
  3. Point nextPoint = null;
  4. int x,y;
  5. x=this.getLocation().getPoint().getX();
  6. y=this.getLocation().getPoint().getY();
  7. //System.out.println(nextPoint.toString());
  8. switch (this.getLocation().getOrientation())
  9. {
  10. case West:
  11. {
  12. while(x>0&&y==0)
  13. nextPoint=new Point(x-getSpeed(),y);
  14.  
  15. while(x>0&&y==216)
  16. nextPoint=new Point(x-getSpeed(),y);
  17.  
  18. while(x>0&&y==500)
  19. nextPoint=new Point(x-getSpeed(),y);
  20.  
  21. if (x==0&&y==0)
  22. getLocation().setOrientation(Orientation.South);
  23.  
  24. if(x==0&&y==216)
  25. getLocation().setOrientation(randomOrientation(Orientation.South, Orientation.North));
  26.  
  27. if(x==0&&y==500)
  28. getLocation().setOrientation(Orientation.North);
  29.  
  30. nextPoint=new Point(x-getSpeed(),y);
  31. break;
  32. }
  33. case East:
  34. {
  35. //nextPoint=new Point(x+getSpeed(),y);
  36. while(x<710&&y==0)
  37. nextPoint=new Point(x+getSpeed(),y);
  38.  
  39. while(x<710&&y==216)
  40. nextPoint=new Point(x+getSpeed(),y);
  41.  
  42. while(x<710&&y==500)
  43. nextPoint=new Point(x+getSpeed(),y);
  44.  
  45. if (x==710&&y==0)
  46. getLocation().setOrientation(Orientation.South);
  47.  
  48. if(x==710&&y==216)
  49. getLocation().setOrientation(randomOrientation(Orientation.South, Orientation.North));
  50.  
  51. if(x==710&&y==500)
  52. getLocation().setOrientation(Orientation.North);
  53.  
  54. nextPoint=new Point(x+getSpeed(),y);
  55. break;
  56. }
  57. // //nextPoint=new Point(x,y+getSpeed());
  58. // //setCanMove(false);
  59. // //getLocation().setOrientation(Orientation.South);
  60. //
  61.  
  62. case North:
  63. {
  64. while(y>0&&x==0)
  65. nextPoint=new Point(x,y-getSpeed());
  66.  
  67. while(y>0&&x==710)
  68. nextPoint=new Point(x,y-getSpeed());
  69.  
  70. if (x==0&&y==0)
  71. getLocation().setOrientation(Orientation.East);
  72.  
  73. if(x==0&&y==216)
  74. getLocation().setOrientation(randomOrientation(Orientation.North, Orientation.East));
  75.  
  76. if(x==710&&y==0)
  77. getLocation().setOrientation(Orientation.West);
  78.  
  79. if (x==710&&y==216)
  80. getLocation().setOrientation(randomOrientation(Orientation.North, Orientation.West));
  81.  
  82. nextPoint=new Point(x,y-getSpeed());
  83. break;
  84. }
  85. case South:
  86. {
  87. while(y<500&&x==0)
  88. nextPoint=new Point(x,y+getSpeed());
  89.  
  90. while(y<500&&x==710)
  91. nextPoint=new Point(x,y+getSpeed());
  92.  
  93. if (x==0&&y==500)
  94. getLocation().setOrientation(Orientation.East);
  95.  
  96. if(x==0&&y==216)
  97. getLocation().setOrientation(randomOrientation(Orientation.South, Orientation.East));
  98.  
  99. if(x==710&&y==500)
  100. getLocation().setOrientation(Orientation.West);
  101.  
  102. if (x==710&&y==216)
  103. getLocation().setOrientation(randomOrientation(Orientation.South, Orientation.West));
  104.  
  105. nextPoint=new Point(x,y+getSpeed());
  106. break;
  107. }
  108. }
  109. return nextPoint;
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement