0 Membres et 1 Invité sur ce sujet
// Load a texture from a filesf::Texture texture;if (!texture.loadFromFile("texture.png"))return -1;// Assign it to a spritesf::Sprite sprite;sprite.setTexture(texture);while (app.isOpen()) { // Process events sf::Event event; while (app.pollEvent(event)) { // Close window : exit if (event.type == sf::Event::Closed) app.close(); if(sf::Keyboard::isKeyPressed(sf::Keyboard::Q)) sprite.move(-10,0); if(sf::Keyboard::isKeyPressed(sf::Keyboard:)) sprite.move(10,0); if(sf::Keyboard::isKeyPressed(sf::Keyboard::S)) sprite.move(0,10); if(sf::Keyboard::isKeyPressed(sf::Keyboard::Z)) sprite.move(0,-10); if(sf::Keyboard::isKeyPressed(sf::Keyboard::Left)) sprite.move(-10,0); if(sf::Keyboard::isKeyPressed(sf::Keyboard::Right)) sprite.move(10,0); if(sf::Keyboard::isKeyPressed(sf::Keyboard::Down)) sprite.move(0,10); if(sf::Keyboard::isKeyPressed(sf::Keyboard::Up)) sprite.move(0,-10); } // Clear screen app.clear(sf::Color(185, 215, 255)); app.draw(sprite); // Update the window app.display(); }