Generic game programming / C# thread

Anything else
User avatar
Korban3
Posts: 4146
Joined: Tue May 31, 2011 9:14 pm
Location: 42nd St E, Hell

Re: Generic game programming / C# thread

Post by Korban3 » Fri Nov 04, 2011 12:03 am

I'll be sure to try to not forget :P
You can always check my twitter as well. I don't update much more than once a day, and sometimes not even that. But I usually put info on there when it happens.
http://twitter.com/#!/ButtsGames

User avatar
Endoperez
Posts: 5668
Joined: Sun Jan 11, 2009 7:41 am
Location: cold and dark and lovely Finland

Re: Generic game programming / C# thread

Post by Endoperez » Sun Nov 06, 2011 10:38 am

blood-shard wrote:Nice to hear about your progress :D

Please get back to us as soon as possible, on how that's gonna turn out :)

The functions for generating random numbers are usually under Math. C# didn't do it this way. I think you had to create an object from the Random class, and then use that object to call the functions that return random values. Something like this:

Random rand_numbers = new Random();

int diceroll = rand_numbers.Next(1,6);

edit: this is a better example
edit2: it seems that in Random.Next(int minvalue, int maxvalue) argument minvalue is inclusive, but maxvalue is exclusive. So the original example above generates numbers 1, 2, 3, 4 or 5 but NOT 6. For a normall dice roll, you'd need:

int diceroll = rand_numbers.Next(1,7);
Last edited by Endoperez on Sun Nov 06, 2011 10:41 am, edited 1 time in total.

User avatar
blood-shard
Posts: 499
Joined: Mon Oct 20, 2008 5:31 pm
Location: in a house in a heartbeat 28 miles away 28 days later

Re: Generic game programming / C# thread

Post by blood-shard » Sun Nov 06, 2011 10:41 am

Endoperez wrote:
blood-shard wrote:Nice to hear about your progress :D

Please get back to us as soon as possible, on how that's gonna turn out :)

The functions for generating random numbers are usually under Math. C# didn't do it this way. I think you had to create an object from the Random class, and then use that object to call the functions that return random values. Something like this:

Random rand_numbers = new Random();

int diceroll = rand_numbers.Next(1,6);

edit: this is a better example
Thanks for some input on that. I'll look into it.

Post Reply