I'll be sure to try to not forget
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
Generic game programming / C# thread
Re: Generic game programming / C# thread
blood-shard wrote:Nice to hear about your progress
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.
-
- 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
Thanks for some input on that. I'll look into it.Endoperez wrote:blood-shard wrote:Nice to hear about your progress
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