Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SFML/Graphics.hpp>
- #include <iostream>
- #include <string>
- using namespace std;
- using namespace sf;
- int main()
- {
- system("dir");
- RenderWindow window(VideoMode(720, 720), "My Window");
- Texture texture;
- if (!texture.loadFromFile("sand.png", IntRect(8, 8, 32, 32)))
- {
- cout << "FIle not found" << endl;
- }
- Sprite sprite;
- sprite.setTexture(texture);
- while (window.isOpen()) {
- Event event;
- while (window.pollEvent(event)) {
- switch (event.type) {
- case Event::Closed:
- window.close();
- case Event::MouseButtonPressed:
- if (event.mouseButton.button == Mouse::Left) {
- if (event.mouseButton.x == 150 && event.mouseButton.y == 150) {
- cout << "YOu win" << endl;
- }
- cout << event.mouseButton.x << endl;
- cout << event.mouseButton.y << endl;
- }
- default:
- break;
- }
- }
- window.clear(Color::Black);
- // draw everything here...
- window.draw(sprite);
- // end the current frame
- window.display();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement