Coordinate startPoint = new Coordinate(x,y);
double angle = Math.toDegrees(Angle.angle(startPoint, new Coordinate(0,0)));
Turtle t = new Turtle(startPoint, angle);
//t.turn(45);
t.move(32);
roadQueue.add(new Road(new Intersection(startPoint), new Intersection(t.pos), RoadType.HIGHWAY, basicRule));
}
int highwayCount = Math.max((city.sizeX*2+city.sizeY*2)/(3*1024),1);
for(int i=0; i<highwayCount; i++){
//highway from random side
int direction = Math.abs(city.random.nextInt()%4);
float length = 128;
switch(direction){
case 0:{ //North
log.log("Highway from the north");
float x = (float) ((this.city.random.nextFloat()-.5)*city.sizeX); //can place in center half of city
Coordinate startPoint = new Coordinate(x, city.sizeY/2);
Turtle t = new Turtle(startPoint, ((city.random.nextDouble()*180)%seedHighwayAngleSize)+270);
t.move(length);
roadQueue.add(new Road(new Intersection(startPoint), new Intersection(t.pos), RoadType.HIGHWAY, basicRule));
break;
}
case 1:{ //South
log.log("Highway from the south");
float x = (float) ((this.city.random.nextFloat()-.5)*city.sizeX); //can place in center half of city
Coordinate startPoint = new Coordinate(x, -city.sizeY/2);
Turtle t = new Turtle(startPoint, ((city.random.nextDouble()*180)%seedHighwayAngleSize)+90);
t.move(length);
roadQueue.add(new Road(new Intersection(startPoint), new Intersection(t.pos), RoadType.HIGHWAY, basicRule));
break;
}
case 2:{ //East
log.log("Highway from the east");
float y = (float) ((this.city.random.nextFloat()-.5)*city.sizeY);
Coordinate startPoint = new Coordinate(-city.sizeX/2, y);
Turtle t = new Turtle(startPoint, ((city.random.nextDouble()*180)%seedHighwayAngleSize)+0);
t.move(length);
roadQueue.add(new Road(new Intersection(startPoint), new Intersection(t.pos), RoadType.HIGHWAY, basicRule));
break;
}
case 3:{ //West
log.log("Highway from the west");
float y = (float) ((this.city.random.nextFloat()-.5)*city.sizeY);
Coordinate startPoint = new Coordinate(city.sizeX/2, y);
Turtle t = new Turtle(startPoint, ((city.random.nextDouble()*180)%seedHighwayAngleSize)+180);
t.move(length);
roadQueue.add(new Road(new Intersection(startPoint), new Intersection(t.pos), RoadType.HIGHWAY, basicRule));
break;
}
default:{
System.out.println("You done goofed. Check the seedRoadMap function's direction variable");
}