Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: How works Randomizer in SFML 1.6  (Read 2998 times)

0 Members and 1 Guest are viewing this topic.

mimipim

  • Newbie
  • *
  • Posts: 49
    • View Profile
How works Randomizer in SFML 1.6
« 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.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
How works Randomizer in SFML 1.6
« Reply #1 on: June 24, 2011, 12:57:25 am »
Just look at Randomizer.cpp, the implementation is open-source.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
How works Randomizer in SFML 1.6
« Reply #2 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
Laurent Gomila - SFML developer

mimipim

  • Newbie
  • *
  • Posts: 49
    • View Profile
How works Randomizer in SFML 1.6
« Reply #3 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 ?

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
How works Randomizer in SFML 1.6
« Reply #4 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.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

mimipim

  • Newbie
  • *
  • Posts: 49
    • View Profile
How works Randomizer in SFML 1.6
« Reply #5 on: June 24, 2011, 11:43:38 am »
Thanks guys! I fixed it.  :)