each time i press A key to move the ball i dont see any move while in console i can see the coordinates changing.
secondly when i click on console menu and then again select(click) the graphic menu i could see the ball(circle) have changed its position .
why i am unable to see the change when i press key "A"..
On line 1, change the code to while (true).
This will allow the loop to be executed repeatedly and move the ball. This is because win.isOpen() will always be false. So you could also change it to while (!win.isOpen()).
while (win.isOpen()) {...} is a proper way of setting up a main loop in SFML. The problem is something else. (What exactly, I don't know.) Note that you are only moving 0.1 each frame, so it takes 10 frames to move a pixel.
OP, can give you give a simplified version (if needed) of your full, compilable code, that still replicates the problem?
10 frames isnt a problem the problem is that is press a few times then i minimize the graphic window and after maximizing it back i could see the ball at a new position ..
Again, you should post a complete, minimal example of your problem in code.
I didn't say that was the problem, I just wanted to confirm you were aware of that.
Keyboard
The class that provides access to the keyboard state is sf::Keyboard. It only contains one function, isKeyPressed, which checks the current state of a key (pressed or released). It is a static function, so you don't need to instantiate sf::Keyboard to use it.
---> This function directly reads the keyboard state, ignoring the focus state of your window. This means that isKeyPressed may return true even if your window is inactive. <---
1 2 3 4 5
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
{
// left key is pressed: move our character
character.move(1, 0);
}
win.display() is called inside the while loop check the very first code ..
also i have a video clip which can better explain this problem ..
but i dont know how to share that here