Welcome
Welcome to a320

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. Registration is fast, simple, and absolutely free, so please, join our community today!

RandomGenerator?

Any and all A320 homebrew topics

Moderator: Moderators

RandomGenerator?

Postby Wiredbomb0 on Tue May 19, 2009 12:05 pm

Just wanting to know, how do you set up and get a random number generator using the s2dsdk. I've added a RandomGenerator member (m_Random) but when I do the m_Random->rand(), there is no variables that I use to define the numbers I want it to pick randomly from. Can someone help me set up a random number generator generator, please?
Wiredbomb0
 
Posts: 166
Joined: Thu Apr 23, 2009 10:08 am
Location: Victoria, Australia

Re: RandomGenerator?

Postby flatmush on Tue May 19, 2009 4:26 pm

Usually to get a random number in the range 0 -> number you call:
rand() % number
% is modulus (the remainder of a division), and rand() is whatever random function you have accessible.
To get a negative number, you simply have to subtract.


PS: The S2DSDK is poo, check out the code for minesweeper, it has stdlib's rand() function implemented.
C99 samples without using s2dsdk | MineSweeper | AstroLander
For help with dingoo programming or just in general, join our IRC at irc://irc.freenode.net/#dingoo-a320
flatmush
 
Posts: 30
Joined: Thu May 14, 2009 1:29 pm
Location: Manchester, UK

Re: RandomGenerator?

Postby Wiredbomb0 on Tue May 19, 2009 10:12 pm

I'll take a look at it when I get home from school, thanks!
Wiredbomb0
 
Posts: 166
Joined: Thu Apr 23, 2009 10:08 am
Location: Victoria, Australia


Return to Homebrew

Who is online

Users browsing this forum: nine10 and 2 guests