Ok, here is most of my code (left out the unnecessary code, collision checking etc.), why isen't this fps-independent?
#define MAX_FORCE 2.05
#define BLOCK_SIZE 32
int main()
{
sf::RenderWindow Game(sf::VideoMode(640, 480), "Platform");
sf::Event Event;
sf::Image imgPlr;
if(!imgPlr.LoadFromFile("./data/block.png"))
return EXIT_FAILURE;
imgPlr.SetSmooth(false);
sf::Sprite sprPlr(imgPlr, sf::Vector2f(128.f, 64.f));
bool jumping = false;
bool standing = false;
float x = 128.f;
float y = 64.f;
float force = 0.f;
float frameRate;
float gravity = 3.14f;
float offset = 0.f;
while(Game.IsOpened())
{
Game.Clear();
while(Game.GetEvent(Event))
{
switch(Event.Type)
{
case sf::Event::KeyPressed:
if(Event.Key.Code == sf::Key::Escape)
Game.Close();
}
}
frameRate = Game.GetFrameTime();
const sf::Input& Input = Game.GetInput();
if(Input.IsKeyDown(sf::Key::Left))
x -= 60 * frameRate;
if(Input.IsKeyDown(sf::Key::Right))
x += 60 * frameRate;
if(Input.IsKeyDown(sf::Key::X) && !jumping && standing)
{
jumping = true;
standing = false;
force = -2.f;
}
else
{
if(!standing)
force += gravity * frameRate;
if(force > MAX_FORCE)
force = MAX_FORCE;
}
y += force - offset;
sprPlr.SetPosition(x, y);
Game.Draw(sprPlr);
Game.Display();
}
return EXIT_SUCCESS;
}