SFML community forums
Help => Graphics => Topic started by: ravenheart on September 22, 2008, 07:10:28 pm
-
Hi i want a shape to move when up / down is pressed
if ((Event.Type == Event.KeyPressed) && (Event.Key.Code == Key::Up))
{
Polygon.Move(0,-5);
//Polygon.Rotate(15);
}
if ((Event.Type == Event.KeyPressed) && (Event.Key.Code == Key::Down))
{
Polygon.Move(0,5);
//Polygon.Rotate(15);
}
but it flickers how can i make it move smoothly?
-
Read the tutorial, use the predefined functions like this to set a bool:
bool LeftKeyDown = Input.IsKeyDown(sf::Key::Left);
bool RightKeyDown = Input.IsKeyDown(sf::Key::Right);
bool UpKeyDown = Input.IsKeyDown(sf::Key::Up);
bool DownKeyDown = Input.IsKeyDown(sf::Key::Down);
Then check against the bools instead!
-
why doesnt that work:
Input i;
bool down = i.IsKeyDown(Key::Down) ;
if(down)
Polygon.Move(0,-10);
-
Probably because you didn't read the tutorial ;)
-
what tutorial are u talking about i cant find it
is this missing?
const sf::Input& Input = App.GetInput();
-
This one :
http://www.sfml-dev.org/tutorials/1.3/window-events.php