while window pollEvent event switch event type case sf Event Closed wi

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
while (window.pollEvent(event)) {
switch (event.type) {
case sf::Event::Closed:
window.close();
break;
case sf::Event::KeyPressed:
if (sf::Keyboard::isKeyPressed(sf::Keyboard::A)) {
character_rect.move(sf::Vector2f(-1, 0));
if (rotate == 0) {
character_rect.scale(sf::Vector2f(-1, 1));
rotate = 1;
}
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::D)) {
character_rect.move(sf::Vector2f(1, 0));
if (rotate == 1) {
character_rect.scale(sf::Vector2f(-1, 1));
rotate = 0;
}
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Space)) {
character_rect.move(sf::Vector2f(0, -100));
character_rect.move(sf::Vector2f(0, 100));
}
break;
}
}