[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Shooting an object



Make sure you store the position as a float internally and cast back
to int (if needed) for display.  Otherwise, you can get some annoying
issues when the speed is low compared to the framerate.

On 8/23/08, yanom @linuxmail.org <yanom@xxxxxxxxxxxxx> wrote:
>
>> ----- Original Message -----
>> From: "Ian Mallett" <geometrian@xxxxxxxxx>
>> To: pygame-users@xxxxxxxx
>> Subject: Re: [pygame] Shooting an object
>> Date: Sat, 23 Aug 2008 13:36:28 -0700
>>
>>
>> OK, for shooting, you want to have a class of Bullet.  When the enemy
>> fires,
>> add an instance of bullet.  The bullet's position will be the enemy's
>> position, and the speed will be a constant broken into x and y components
>> with cos(radians(angle)) and sin(radians(angle)).  Each frame, you add the
>> speed of the bullet to the bullet's position.
>
>>
> ok thanks
>
> =
> Tours from Las Vegas
> Bus & Air Tours to the Grand Canyon Monument Valley, Bryce & Zion.
> http://a8-asy.a8ww.net/a8-ads/adftrclick?redirectid=5ec9e22c3648e0f36638288f64c6b564
>
>
> --
> Powered by Outblaze
>