Hello,
I'm trying to draw a background with like > 100 Stars. The stars are simple 1px-rectangles, which I store in an array.
sf::Shape Stars[100];
I initialize all the Shapes at start and calculate random positions, which works fine - also the drawing works fine.
I want to move the Shapes along the y-axis, so they move down. If they are out of screen I want to reset the y-position to 0.
The function looks like:
for (int i = 0; i < 100; i++) {
if (Stars[i].GetPosition().y <= pWindow->GetHeight()) {
Stars[i].Move(0, 5);
} else {
Stars[i].SetPosition(Stars[i].GetPosition().x, 0.f);
}
}
The problem is:
Stars move down. No star's y-position will be set to 0.
Only when the 'first' (the star, which has the lowest y-value) is at the end of the screen,
all of the star's y-position will be set to the standard value (the calculaled random positions, because the stars-composition looks like at the beginning of the application).
I'm confused. All the asteroids and shots work fine. I'm using sf::Sprite for them and vectors to store them.
Greetigs,
Luinechor
Update:
It works now!Got it working with the help of this thread:
http://sfml-dev.org/forum/viewtopic.php?t=679&highlight=shape