ok so i create my polygon right here
Polygon poly;
public void createDetectionRadius(Graphics2D g, int xpos, int ypos, double size, int width, int height){
poly = new Polygon();
poly.addPoint(xpos, ypos);
poly.addPoint(xpos-(int)size*width, ypos+50+(int)size*height);
poly.addPoint(xpos - width*3-(int)size*(int)size + height, ypos+(int)size*height*2-(int)size*2);
poly.addPoint(xpos, ypos+(int)size*height*2);
poly.addPoint(xpos + width*3+(int)size*(int)size - height, ypos+(int)size*height*2-(int)size*2);
poly.addPoint(xpos+(int)size*width, ypos+50+(int)size*height);
g.drawPolygon(poly);
}
here is where i do the method
if(Map.player.detectedPlayer){
double dx = xpos - Map.player.xpos + 8 - Map.xOffset;
double dy = ypos - Map.player.ypos - Map.yOffset;
rotation = -Math.atan2(dx, dy);
rotation = Math.toDegrees(rotation) + 180;
}
// g.rotate(rotation,
// xpos - Map.xOffset + width / 2 ,
// ypos - Map.yOffset + height / 3);
g.rotate(Math.toRadians(rotation),
xpos + width / 2 - Map.xOffset,
ypos + height / 3 - Map.yOffset);
//HERE!!!!!!!!!!!!!
createDetectionRadius(g,
(int) (xpos - Map.xOffset + width / 2)
,(int) (ypos - Map.yOffset + height - height / 3), 5, 20, 20);
//HERE!!!!!!!!!!!!!
g.drawImage(pipe, (int) (xpos - Map.xOffset),(int) (ypos - Map.yOffset), width,height,null);
if(Map.player.detectedPlayer){
g.setColor(Color.RED);
}else{
g.setColor(Color.WHITE);
}
g.drawLine(
(int) (xpos + width / 2 - Map.xOffset),
(int) (ypos - Map.yOffset),
(int) (xpos + width / 2 - Map.xOffset),
(int) (ypos + detectionSize+width*4+20 - Map.yOffset));
g.rotate(-Math.toRadians(rotation),
xpos + width / 2 - Map.xOffset,
ypos + height / 3 - Map.yOffset);
when the polygons are draw thay do rotate and all, its just that the collision does not work, the collision box does not rotate with the drawn polygons!!
if(poly != null){
if(poly.intersects(Map.player.getBounds())){
Map.player.isDetected(true);
}else{
Map.player.isDetected(false);
}
}
the collision does not move or rotate so it wont work
tell me if you want better explanation on what all variables are!
here are 2 images of what is happening
http://s30.postimg.org/4cbq8hqzl/image.png
the red lines are where the collision is so the collision polygons are not rotating for some reason!
here is me standing the the box // thats why the colors changed!
http://s30.postimg.org/j9k79i481/image.png
so basically the collision works but the collision polygons wont rotate with the drawn polygons!