i have 2 spaceships. both have polygons. (hitbox) spaceships can be rotated. sooo bounds don't work.
my way to find intersects:
if (hitbox.intersects(enemyHitbox.getBoundsInLocal())){
for (int i = 0; i < enemy.length; i++) {
if (hitbox.contains(enemy[i].getX(), enemy[i].getY())) {
System.out.println("HIT");
} else if (enemyHitbox.contains(p1)) {
System.out.println("HIT p1");
} else if (enemyHitbox.contains(p2)) {
System.out.println("HIT p2");
} else {
}
}
}
but... there is a problems. when real intersect, but vertex not inside polygon (imagine 2 triangles. 1st have angle 0 and 2nd 180. )
Is there any way to fix? Maybe java have some solution for that?