Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int moveX = (int) (Math.floor((Math.random() * 3)) - 1);
- int moveY = (int) (Math.floor((Math.random() * 3)) - 1);
- int tgtX = this.getLocation().getX() + moveX;
- int tgtY = this.getLocation().getY() + moveY;
- sprite = Misc.direction(this.getLocation().getX(), this.getLocation().getY(), tgtX, tgtY);
- if (tgtX > this.maximumCoords.getX() || tgtX < this.minimumCoords.getX() || tgtY > this.maximumCoords.getY() || tgtY < this.minimumCoords.getY()) {
- sprite = -1;
- }
- if (sprite != -1) {
- sprite >>= 1;
- this.setLocation(Location.location(tgtX, tgtY, this.getLocation().getZ()));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement