C++ random function not random
In my c++ code I have a problem. My random drawBlock function which should return xRandom and yRandom is not so random. void Game::drawBlock() { int xRandom, yRandom; std::cout<<time(NULL) << std::endl; xRandom = (rand () % 620) + 1; yRandom = (rand () % 440) + 1; std::cout << "x: " << xRandom << std::endl; std::cout << "y: " << yRandom; mBlock.setSize(sf::Vector2f(20,20)); mBlock.setPosition(xRandom,yRandom); mBlock.setFillColor(sf::Color::Red); } so what basically happens is that the first random number, in this case xRandom isn't really random. When I run the program everything seems fine x
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.