SFML community forums

Help => General => Topic started by: mimipim on June 24, 2011, 12:49:26 am

Title: How works Randomizer in SFML 1.6
Post by: mimipim on June 24, 2011, 12:49:26 am
Laurent, can you share how Randomizer work(code) in SFML 1.6 because now with SFML 2 I can't get same effect with my own rand function (it's seems working like randomizer in sfml 1.6 but....)
 :?

Oups... wrong sub-forum maybe. Sorry.
Title: How works Randomizer in SFML 1.6
Post by: Nexus on June 24, 2011, 12:57:25 am
Just look at Randomizer.cpp, the implementation is open-source.
Title: How works Randomizer in SFML 1.6
Post by: Laurent on June 24, 2011, 07:39:50 am
sf::Randomizer had the simplest implementation possible.

- rand() % range + min for integers
- rand() * range / RAND_MAX + min for floats
Title: How works Randomizer in SFML 1.6
Post by: mimipim on June 24, 2011, 10:18:54 am
Quote from: "Nexus"
Jsf::Randomizer had the simplest implementation possible.

- rand() % range + min for integers
- rand() * range / RAND_MAX + min for floats


Laurent, this seems is not like sf::Randomizer because if I put for range 10 and min = -10 it's returning values from -10 to 0.

EDIT: I'll check now the source file.

EDIT 2: Yep, i found it and source was a litle bit different (just like my function), so this was not the reason my bolt effect is not like my bolt effect in SFML 1.6 with same source.

I'll try to found wath make it different.
Thanks for helping me. :)

I just wanna ask is there something changed in direction or angles in SFML 2 ?
Title: How works Randomizer in SFML 1.6
Post by: Nexus on June 24, 2011, 10:41:34 am
Quote from: "mimipim"
Laurent, this seems is not like sf::Randomizer because if I put for range 10 and min = -10 it's returning values from -10 to 0.
Isn't this exactly how it should be? The interval includes the last value, unlike STL ranges.

Quote from: "mimipim"
I just wanna ask is there something changed in direction or angles in SFML 2 ?
Yes, the sign of angles has been changed in SFML 2. The reasons are explained here (http://www.sfml-dev.org/forum/viewtopic.php?t=4467).
Title: How works Randomizer in SFML 1.6
Post by: mimipim on June 24, 2011, 11:43:38 am
Thanks guys! I fixed it.  :)