OK, I'm going to try my best to explain my problem. I have this program where you can select 5 balls. When you select one, you can drag it while you have the mouse button pressed and the cursor is within the ball's radius.
The problem is that I need a way to make the ball go up when the user stop pressing the mouse button, like he sent it to float in the air then made it fall down again. I have one way to know the time, velocity and thus the acceleration, but I don't know how to implement it.
Right now i have this:
void Circle::Fall(float velocity,float time)
{
if(this->posY >= 580)
{
this->posY = 580;
this->vfall= 0.0f;
}
else if(this->posY < 580)
{
//this->distance=9.81f * 0.5f*time*time;
this->vfall+= velocity;
this->posY += this->vfall;
}
}
With it like this it just falls, and I can't make the effect I tried to explain.
Also, I'm calculating the time like this (just in case it helps):
difX=(x> event.motion.xrel)? x-event.motion.xrel : event.motion.xrel-x;
difY=(y> event.motion.yrel)? y-event.motion.yrel : event.motion.yrel-y;
And I'm using difY
as the time variable
OK, sorry, I made it English now. And I'm going to try to make this easier to understand:
You need to make the ball float a little longer with the speed of the mouse at the moment it releases the click, like a hand throwing a ball into the air after taking some impulse. It does not have to make a U-turn or anything just go up a little on Y. I'm using SDL in case you need to know
Also you take the balls from the bottom of the window and when you release the click on them they return them automatically