problem about bouncing sphere
I can make the ball falling....but till it hit the floor.....it wont jump....dont know y!! can help me check and modify...thanks a lot!!
void MyObject::TickAnimation()
{
pos.fY -= GRAVITY;
pos += vel;
if (pos.fY > CEILING_HEIGHT)
{
vel.fY = -abs(vel.fY);
pos.fY = 2 * CEILING_HEIGHT - pos.fY;
}
else if (pos.fY < GROUND)
{
vel.fY = abs(vel.fY);
pos.fY = 2 * GROUND - pos.fY;
}
}
void MyObject::DrawSelf()
{
glPushMatrix();
glTranslatef(100, pos.fY, 200);
glutSolidSphere(15,30,30);
glPopMatrix();
}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement