Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Point nextLocation()
- {
- Point nextPoint = null;
- int x,y;
- x=this.getLocation().getPoint().getX();
- y=this.getLocation().getPoint().getY();
- //System.out.println(nextPoint.toString());
- switch (this.getLocation().getOrientation())
- {
- case West:
- {
- while(x>0&&y==0)
- nextPoint=new Point(x-getSpeed(),y);
- while(x>0&&y==216)
- nextPoint=new Point(x-getSpeed(),y);
- while(x>0&&y==500)
- nextPoint=new Point(x-getSpeed(),y);
- if (x==0&&y==0)
- getLocation().setOrientation(Orientation.South);
- if(x==0&&y==216)
- getLocation().setOrientation(randomOrientation(Orientation.South, Orientation.North));
- if(x==0&&y==500)
- getLocation().setOrientation(Orientation.North);
- nextPoint=new Point(x-getSpeed(),y);
- break;
- }
- case East:
- {
- //nextPoint=new Point(x+getSpeed(),y);
- while(x<710&&y==0)
- nextPoint=new Point(x+getSpeed(),y);
- while(x<710&&y==216)
- nextPoint=new Point(x+getSpeed(),y);
- while(x<710&&y==500)
- nextPoint=new Point(x+getSpeed(),y);
- if (x==710&&y==0)
- getLocation().setOrientation(Orientation.South);
- if(x==710&&y==216)
- getLocation().setOrientation(randomOrientation(Orientation.South, Orientation.North));
- if(x==710&&y==500)
- getLocation().setOrientation(Orientation.North);
- nextPoint=new Point(x+getSpeed(),y);
- break;
- }
- // //nextPoint=new Point(x,y+getSpeed());
- // //setCanMove(false);
- // //getLocation().setOrientation(Orientation.South);
- //
- case North:
- {
- while(y>0&&x==0)
- nextPoint=new Point(x,y-getSpeed());
- while(y>0&&x==710)
- nextPoint=new Point(x,y-getSpeed());
- if (x==0&&y==0)
- getLocation().setOrientation(Orientation.East);
- if(x==0&&y==216)
- getLocation().setOrientation(randomOrientation(Orientation.North, Orientation.East));
- if(x==710&&y==0)
- getLocation().setOrientation(Orientation.West);
- if (x==710&&y==216)
- getLocation().setOrientation(randomOrientation(Orientation.North, Orientation.West));
- nextPoint=new Point(x,y-getSpeed());
- break;
- }
- case South:
- {
- while(y<500&&x==0)
- nextPoint=new Point(x,y+getSpeed());
- while(y<500&&x==710)
- nextPoint=new Point(x,y+getSpeed());
- if (x==0&&y==500)
- getLocation().setOrientation(Orientation.East);
- if(x==0&&y==216)
- getLocation().setOrientation(randomOrientation(Orientation.South, Orientation.East));
- if(x==710&&y==500)
- getLocation().setOrientation(Orientation.West);
- if (x==710&&y==216)
- getLocation().setOrientation(randomOrientation(Orientation.South, Orientation.West));
- nextPoint=new Point(x,y+getSpeed());
- break;
- }
- }
- return nextPoint;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement