Just ported it to SFML 2.0 and tested it, the problem is obviously in the window collision as it just goes through, I'll fix it later as I have no time in my hands right now, but here's the ported version:
int main()
{
sf::RenderWindow Game(sf::VideoMode(800, 600, 32), "Ball ... ");
sf::Clock Clock;
sf::Texture bg;
bg.loadFromFile("C:/Users/Carlos/Desktop/Sprites/Flame Shot Basic 1.png");
sf::Sprite ball;
ball.setOrigin(60,120);
ball.setTexture(bg);
ball.setPosition(300,120);
bool running = true;
float g = 0.6;
int s = 595;
int y;
int i=1;
bool move = false;
int vy;
int v = 1;
float t = 1;
sf::Event Event;
while(running == true)
{
if(i == 1)
{
ball.move(0,g*Clock.getElapsedTime().asSeconds());
}
y = ball.getPosition().y;
std::cout<<"y= "<<y<<"\n";
std::cout<<"s= "<<s<<"\n";
if(y == s)
{
v = g*Clock.getElapsedTime().asSeconds();
move = true;
i++;
Clock.restart();
}
if(move == true && i>1)
{
vy -= (v - g*Clock.getElapsedTime().asSeconds());
if(vy == 0)
{
Clock.restart();
move = false;
}
ball.move(0,vy);
}
if(i>1 && move == false)
{
ball.move(0,g*(Clock.getElapsedTime().asSeconds()));
}
while(Game.pollEvent(Event))
{
}
Game.clear();
Game.draw(ball);
Game.display();
}
return 0;
}
You could easily simplify the code and instead of having many conditionals you just check if the sprite has reached either top or bottom of the window's y and have it move in a determined speed (positive or negative accordingly), instead of making mangles with clocks for something as simple as that.