When
srand((unsigned)time(NULL));
called before RenderWindow class object creation, rand() return same value, like srand() initialize by const var.
If i will put srand after RenderWindow creation, everything OK.
see attached screenshot
I'm confused that the example "examples/pong/Pong.cpp" uses a similar code:
https://github.com/SFML/SFML/blob/fae3b65f0567f87fa9925cd42d28df15eb69e79c/examples/pong/Pong.cppsrand before RenderWindow
P.S. sorry for my English, it's my second language.
code and compile parameters:
#include <SFML/Graphics.hpp>
#include <iostream>
#include <time.h>
using namespace sf;
int main()
{
VideoMode vdm = VideoMode(400, 533);
srand((unsigned)time(NULL));
RenderWindow app(vdm, "Game!");
for (int i=0;i<10;i++)
{
std::cout << rand()%100 << " " << rand()%100 << "\n";
}
return 0;
}
// g++ main2.cpp -lsfml-graphics -lsfml-window -lsfml-system -std=c++11