so, why doesnt this code not work, i think about the movement - Input
int main()
{
// Create main window
RenderWindow App;
App.Create(sf::VideoMode(WINDOW_WIDTH,WINDOW_HEIGHT,32), "SFML Window", Style::Fullscreen);
// Cursor is not being shown
ShowCursor(0);
// create bats
bat left;
bat right;
right.SetPosition(WINDOW_WIDTH - right.width,0);
// INput
const Input& Input = App.GetInput();
bool left_up = Input.IsKeyDown(Key::W);
bool left_down = Input.IsKeyDown(Key::S);
bool right_up = Input.IsKeyDown(Key::Up);
bool right_down = Input.IsKeyDown(Key::Down);
// Geschwindigkeiten
while (App.IsOpened())
{
// Process events
Event Event;
while (App.GetEvent(Event))
{
// Close window : exit
if (Event.Type == Event.Closed)
App.Close();
// keybord-events
if ((Event.Type == Event.KeyPressed) && (Event.Key.Code == Key::Escape))
{
App.Close();
}
}
// handle bat-movements
if( right_down)
{
right.Move(0, 400* App.GetFrameTime());
}
if(right_down)
{
right.Move(0, - 400 * App.GetFrameTime());
}
if(left_down)
{
left.Move(0, 400* App.GetFrameTime());
}
if(left_up)
{
left.Move(0, -400* App.GetFrameTime());
}
// Draw left paddle;
App.Draw(left);
App.Draw(right);
// Finally, display the rendered frame on screen
App.Display();
}
my bats dont move, when i write my input right above the if-clauses everything works fine, why?
does App.GetInput() needs to be refreshed every frame?