Well, I will try my best to explain my problem. I have this program where you can choose 5 goals. When you select it, you can drag it while you click the mouse button, and the cursor is within the radius of the ball.
The problem is that I need a way to make the ball rise when the user stops pressing the mouse button, as if he sent it to the float in the air, and then fell again. I have one way to find out time, speed, and therefore acceleration, but I don’t know how to implement it.
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->vfall+= velocity;
this->posY += this->vfall;
}
}
With this, he simply falls, and I cannot make the effect that I was trying to explain.
In addition, I am calculating a 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 use difYas a time variable
, , . :
, , , . - Y. SDL,
, ,