Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. int moveX = (int) (Math.floor((Math.random() * 3)) - 1);
  2. int moveY = (int) (Math.floor((Math.random() * 3)) - 1);
  3. int tgtX = this.getLocation().getX() + moveX;
  4. int tgtY = this.getLocation().getY() + moveY;
  5. sprite = Misc.direction(this.getLocation().getX(), this.getLocation().getY(), tgtX, tgtY);
  6. if (tgtX > this.maximumCoords.getX() || tgtX < this.minimumCoords.getX() || tgtY > this.maximumCoords.getY() || tgtY < this.minimumCoords.getY()) {
  7. sprite = -1;
  8. }
  9. if (sprite != -1) {
  10. sprite >>= 1;
  11. this.setLocation(Location.location(tgtX, tgtY, this.getLocation().getZ()));
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement