Circle enemy detection in TD game
<p>I'm working on a Java tower defense game, but I've got a problem: I cant make the tower find enemies within a circle. My code:</p>

<pre><code>if(twrsq.intersects(GameScreen.enemies[i])) {
    shooting = true;
    shotEnemy = i;
}
this.twrsq = new Rectangle(
    x - (twrsqsize/2), y - (twrsqsize/2),
    width + twrsqsize, height +  twrsqsize);
</code></pre>

<p><code>twrsq</code> holds the current rectangle; this needs to be a circle. <code>GameScreen.enemies[i]</code> holds a rectangle too. I'm trying to make a circle from <code>twrsq</code> and make them intersect with the enemy.</p>

<p>How can I accomplish this?</p>

<p>Edit:  I got it kinda working; I got now this <a href="http://screenshotuploader.com/s/01/2a383Cl1x" rel="nofollow">screenshot</a>:</p>

<pre><code>if(cir.intersects(GameScreen.enemies[i])) {
    shooting = true; shotEnemy = i;
} 
</code></pre>
