First delete this section
if (jumping == true)
{
myDot.yVel -= 120;
if (myDot.yVel < -240)
{
myDot.yVel = 240;
myDot.yVel = 0;
jumping = false;
}
}
Then go to your Dot class, add a "int gravity" and a "int maxY" variables.
On the Dot class constructor, initalize the gravity to, for example 10, and the maxY to 240.
Now on the Dot::move method, insert the following:
//Only execute if the box is jumping
if(jumping)
{
//If the box is falling at the maximum speed (maxY serves as the maximum up speed, as well as maximum down speed)
if(yVel - gravity < -maxY)
yVel = -maxY; //Don't increment yVel, instead make it fall at exactly the maximum speed
//Else, the box as yet to reach the maximum downfall speed, so add the gravity to the falling speed
else
yVel -= gravity;
//Update the box's y position every frame
Box.y += yVel;
//Check if the box hit the floor
if( (box.y < 0) || (box.y + DOT_HEIGHT > LEVEL_HEIGHT ) || touches_wall( box, tiles ) )
jumping = false; //Disable jumping
}
and lastly in
case SDLK_UP:
if (!jumping)
{
jumping = true;
yVel = 0;
} break;
set yVel to maxY instead.
NOTE: Your code seems to have the Y values inverted (top is 0, bottom is window_height), if it is so, then invert the signs of the jumping in the move function.
See if it works.