SFML community forums

Help => Graphics => Topic started by: drew on August 11, 2009, 12:01:01 am

Title: Random sf::String?
Post by: drew on August 11, 2009, 12:01:01 am
How would I go about generating a random character to put into sf::String? I didn't see anything in sf::Randomizer to do that...

Thanks.
Title: Random sf::String?
Post by: Imbue on August 11, 2009, 01:07:36 am
You could try something like:
Code: [Select]
char random = 'a' + sf::Randomizer::Random(0, 25);For a random letter from 'a' to 'z'.
Title: Random sf::String?
Post by: drew on August 11, 2009, 01:30:03 am
Yeah but I'm wanting to put it into sf::String so it can be drawable using fonts. As far as I can tell sf::String constructor doesn't take std::string or char so I'm not sure what to do.

...oh I'm sorry. I just figured it out after digging through the sf::String and sf::Unicode docs. Apparently that's how! Alright so it's just passing std::string to sf::Unicode::Text and finally passing that to sf::String.