#include #include #include #include "Images.h" int width = 1000, height = 800; int main() { sf::VideoMode videoModes(width, height); sf::RenderWindow renderWindow(videoModes, "Demo Game"); sf::Texture texture; texture.loadFromFile("three.png"); sf::Vector2u oldSize = renderWindow.getSize(); sf::Sprite sprite; sprite.setTexture(texture); sprite.setTextureRect(sf::IntRect(0, 0, videoModes.width, videoModes.height)); sprite.setColor(sf::Color(255, 255, 255, 200)); sprite.setPosition(0, 0); bool hold = false; Vector2i oldPos; sf::RectangleShape q(Vector2f(100, 100)); Vector2u oldWindow(1,1); Texture image, background; background.loadFromFile("DigitBg.jpg"); image.loadFromFile("three.png"); q.setTexture(&image); Sprite bg; bg.setTexture(background); while (renderWindow.isOpen()) { sf::Event event; while (renderWindow.pollEvent(event)) { if (event.type == sf::Event::EventType::Closed) renderWindow.close(); else if (event.type == sf::Event::MouseButtonPressed) { hold = true; oldPos = Mouse::getPosition(); } else if (hold && event.type == sf::Event::MouseMoved) { q.setPosition(q.getPosition().x - oldPos.x + Mouse::getPosition().x, q.getPosition().y - oldPos.y + Mouse::getPosition().y); oldPos = Mouse::getPosition(); } else if (event.type == sf::Event::MouseButtonReleased) hold = false; } renderWindow.clear(); renderWindow.draw(bg); renderWindow.draw(q); renderWindow.display(); oldWindow = renderWindow.getSize(); } return 0; }