If you find this is too slow, you'll get much better performance by
removing the **'s, they're quite slow compared to other arithmetic. Use
x*x instead of x**2 and square both sides of the inequality to remove
the **0.5.
P.F.C. wrote:
I'm not getting the attachment but this might help.
If y
so, I wrote this tower defense game (zip archive attached) and I was wondering
how I should go about implementing limited range (each tower can only shoot so
far) in the code.
I'm not getting the attachment but this might help.
If your doing range as a circle with radius = r then:
if ((enemy.x-tower.x)**2+ (enemy.y-tower.y)**2)**0.5<=r: attack!!!
basically, you'd be using Pythagorean theorem to find the distance to check
if it attacks or not.
Checking distances for e
Attached is an example that handles line breaks manually; it also
handles text wrapping.
2009/11/2 leo kirotawa :
> ok, thanks a lot
>
> On Mon, Nov 2, 2009 at 11:29 PM, Ian Mallett wrote:
>>
>> No; PyGame does not support that. You must handle line breaks manually,
>> rendering as separate surf