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

Re: [pygame] Make a sprite fall with realistic gravity?



By the way:

Pixels are integers, so don't make operations with them, make a variables like:

varX = 0.0
varY = 0.0

And make operations using them or you will lost the decimals (because x and y in the image are integers: pixels). This is visible  when you do a bouncing animation, the animation gradually will lost speed and finish -after many bounces- in the floor, like if it have been a friction force that have stopped it.... So make all operations in a separated variables and before to draw the objects asign the results to the object position (so in the next interaction you will have the exact x and y coordinates to operate with and not something rounded to 'pixels' -int-)

2009/12/1 Rob <robuck@xxxxxxxxx>
Thanks guys, your replies were helpful. The physics links in
particular were very good for refreshing my memory on the equations.

On 11/30/09, R. Alan Monroe <amonroe@xxxxxxxxxxxxxxx> wrote:
>> I've been trying to get a sprite (the ball) to fall from the top of
>> the screen with realistic gravity. I did attempt it, however it's not
>> so great so I won't post it here.
>
> These might help:
>
> http://hyperphysics.phy-astr.gsu.edu/hbase/traj.html
>
> http://www.makingthemodernworld.org/learning_modules/maths/04.TU.02/?section=1
>
> Alan
>
>



--
Nota: Tildes omitidas para evitar incompatibilidades.

:wq