Advertisement
Guest User

Untitled

a guest
Mar 8th, 2017
99
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.02 KB | None
  1. #include <SFML/Graphics.hpp>
  2. #include <iostream>
  3. #include <string>
  4. using namespace std;
  5. using namespace sf;
  6.  
  7. int main()
  8. {
  9.     system("dir");
  10.     RenderWindow window(VideoMode(720, 720), "My Window");
  11.     Texture texture;
  12.    
  13.         if (!texture.loadFromFile("sand.png", IntRect(8, 8, 32, 32)))
  14.         {
  15.             cout << "FIle not found" << endl;
  16.         }
  17.        
  18.  
  19.     Sprite sprite;
  20.     sprite.setTexture(texture);
  21.     while (window.isOpen()) {
  22.        
  23.         Event event;
  24.         while (window.pollEvent(event)) {
  25.             switch (event.type) {
  26.             case Event::Closed:
  27.                 window.close();
  28.             case Event::MouseButtonPressed:
  29.                 if (event.mouseButton.button == Mouse::Left) {
  30.                     if (event.mouseButton.x == 150 && event.mouseButton.y == 150) {
  31.                         cout << "YOu win" << endl;
  32.                     }
  33.                     cout << event.mouseButton.x << endl;
  34.                     cout << event.mouseButton.y << endl;
  35.  
  36.  
  37.                 }
  38.             default:
  39.                 break;
  40.  
  41.  
  42.             }
  43.         }
  44.         window.clear(Color::Black);
  45.        
  46.             // draw everything here...
  47.             window.draw(sprite);
  48.  
  49.         // end the current frame
  50.         window.display();
  51.     }
  52.     return 0;
  53. }
Advertisement
RAW Paste Data Copied
Advertisement