Advertisement
STANAANDREY

sfm_mouse

Apr 13th, 2019
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. #include<iostream>
  2. #include <string>
  3. #include<SFML\Graphics.hpp>
  4. #include"SFML\Window.hpp"
  5. #include"SFML\System.hpp"
  6. #include <windows.h>
  7. using namespace std;
  8. using namespace sf;
  9.  
  10.  
  11. int main()
  12. {
  13.     string s="app";
  14.  RenderWindow window(VideoMode(600,600),s);
  15.  window.setFramerateLimit(60);
  16.     while (window.isOpen())
  17.     {
  18.  
  19.         Event event;
  20.         while (window.pollEvent(event))
  21.         {
  22.             if (event.type == Event::Closed)
  23.                 window.close();
  24.  
  25.             if (event.KeyPressed && event.key.code == Keyboard::Escape)
  26.                 window.close();
  27.  
  28.              if (event.type == sf::Event::MouseButtonPressed)
  29. {
  30.     if (event.mouseButton.button == Mouse::Right)
  31.     {
  32.         std::cout << "the right button was pressed" << std::endl;
  33.         std::cout << "mouse x: " << event.mouseButton.x << std::endl;
  34.         std::cout << "mouse y: " << event.mouseButton.y << std::endl;
  35.     }
  36. }
  37. if (event.type==Event::MouseWheelMoved)
  38. {
  39.  cout<<event.mouseWheel.delta;
  40. }
  41. }
  42.         }
  43.  
  44.  
  45.   system("pause");
  46.     return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement