I have a city-building game and have finished working on the player, who manually selects where to place something. I have not finished to AI, which is supposed to generate a point on the edge of or within it’s territory (an Area object).
Here is the method I am working on:
public Point getBuildPoint(){
Random rand = gp.rand;
int x = -1;
int y = -1;
if(currentState == expandState){
//get point on the edge of the territory
}else{
//get point within the territory
}
//snap to grid
x = Math.round((float) x / gp.tileSize)*gp.tileSize;
y = Math.round((float) y / gp.tileSize)*gp.tileSize;
return new Point(x, y);
}
I looked into using the PathIterator object but didn’t find anything useful.