Hey guys... hope that you are fine... I am having one problem... I have got it to make scrolling objects... I have made an paddle and when it reach the end of the window it generate in the other side of screen... it works fine... but the problem is that I want to make scrolling backgrounds... I more or less know that I have to repeat the texture but I dont know how... I will post here the code of how I made the scrolling paddle:
#include <SFML/Graphics.hpp>
int main(int argc, char* argv[])
{
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML Scrolling Test");
window.setVerticalSyncEnabled(true);
sf::RectangleShape shape(sf::Vector2f(200,30));
shape.setPosition(200, 400);
shape.setFillColor(sf::Color::Blue);
sf::Clock clock;
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
{
window.close();
}
}
if ((shape.getPosition().x + shape.getSize().x) < 0)
{
shape.setPosition((window.getSize().x), (shape.getPosition().y));
}
float deltaTime = clock.restart().asSeconds();
shape.move(-deltaTime * 500, 0);
window.clear();
window.draw(shape);
window.display();
}
}
but the real questions is: How I can apply this to an scrolling background? and how I correctly repeat an texture?
p.s: Sorry about bad English