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

Re: [pygame] Why does my ball vibrate?



Matt Smith wrote:
I can't quite get my head around WHY the ball sinks into the ground if I don't set ypos back to 384 but it certainly works.

It's probably because you're applying gravity to the ball
even when it's touching the ground. So it repeatdly gets
accelerated downwards for one time step, then moved back
up to ground level.

In real life, when the ball is touching the ground, the
downward force of gravity is balanced by an upward force
from the ground, so the net acceleration is zero. You
can model that by only applying gravity if the ball is
above ground level.

--
Greg