Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <SFML/Graphics.hpp>
- int main(){
- sf::RenderWindow window(sf::VideoMode(500, 600), "SFML Tutorial", sf::Style::Titlebar | sf::Style::Close);
- //Main Loop:
- while(window.isOpen()){
- sf::Event Event;
- //Event Loop:
- while(window.pollEvent(Event)){
- switch(Event.type){
- case sf::Event::Closed:
- window.close();
- case sf::Event::KeyPressed:
- if(Event.key.code == sf::Keyboard::Up){
- std::cout << "Up\n";
- }else if(Event.key.code == sf::Keyboard::Down){
- std::cout << "Down\n";
- }else if(Event.key.code == sf::Keyboard::Left){
- std::cout << "Left\n";
- }else if(Event.key.code == sf::Keyboard::Right){
- std::cout << "Right\n";
- }
- }
- }
- window.display();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement