My server is going to use Region objects to split the game world up, such that each player can view a maximum of 4 Regions.
I’ve been told that regions are 104*104. However I decided to dump some logs, and I don’t really follow.
Anyone care to take a look and explain?
This is the code used to obtain the X/Y co-ordinates displayed:
public int getX() {
return x;
}
public int getY() {
return y;
}
public int getHeight() {
return height;
}
public int getLocalX() {
return getLocalX(this);
}
public int getLocalX(Point p) {
return x - 8 * p.getRegionX();
}
public int getLocalY() {
return getLocalY(this);
}
public int getLocalY(Point p) {
return y - 8 * p.getRegionY();
}
public int getRegionX() {
return (x >> 3) - 6;
}
public int getRegionY() {
return (y >> 3) - 6;
}
And this is the code used to print the values out:
for (int i = 0; i < 50; i++) {
for (int y = 0; y < 50; y++) {
Point p = Point.getLocation(i, y, 0);
String output = "\nTile info: X=" + i + " Y=" + y + "\n";
output += "LocalX=" + p.getLocalX() + " LocalY=" +
p.getLocalY() + "\n";
output += "RegionX=" + (p.getRegionX() + 6) + " " +
"RegionY=" + (p.getRegionY() + 6) + "\n";
logger.info(output);
}
}