Hi, in the following codes, i creates a missile that is fired by an enemy and which must seek my ship, but I want the missile to be destroyed if his rotation angle is too big
Here's the code of my missile class:
and the code of the enemy class, which fires the missile:
The problem is that the missile is destroyed as soon as his getRotation is higher than 90°, but i only want it to be destroyed when the difference between a rotation (i) and the rotation(i-1) is higher than 90°...
Could you help me please?^^
private int timer;
public static final int damage = 100;
private int counter = 0;
public boolean seeking;
int[] rotations = new int[1000];
public int i = 1;
public Missile(int rotation)
{
setRotation(rotation);
timer = 0;
}
public void act()
{
if(isPaused() == false)
{
count();
vanish();
disappear();
movements();
timer++;
faceGear();
}
}
private void movements()
{
move(3);
}
public void faceGear()
{
if(getWorld() != null)
{
if(timer % 10 == 0)
{
if(Math.abs(rotations[i]-rotations[(i-1)])<90)
{
Actor gear = (Actor)getWorld().getObjects(Gears.class).get(0);
int xGear = gear.getX();
int yGear = gear.getY();
this.turnTowards(xGear, yGear);
rotations[i] = this.getRotation();
i++;
}
else if (Math.abs(rotations[i]-rotations[(i-1)])>=90)
{
getWorld().removeObject(this);
}
}
}
}private void fire()
{
if(timer>= 100 && attackTimer>= ATTACK_TIMER)
{
Missile missile = new Missile(this.getRotation()+180);
getWorld().addObject(missile, this.getX(), this.getY());
attackTimer = 0;
}
}

