c# - Random number generation for multiple objects -



c# - Random number generation for multiple objects -

so i'm trying create matrix-like programme "raining greenish code". has been going until decided throw of string instances list , draw/update it. in order acheive proper effect need randomize few things.

all strings created , stored in list see here in loop. interval , dropspeed random numbers alter how fast string falls, , @ speed individual characters rotate through sprite sheet.

for reason though i'm getting wall of text falls @ 1 time , sprites rotating @ equal pace. classes , respective functions work...so question doing wrong random number initialization?

for (int = 0; < (wwidth / 30); i++) { random random = new random(new system.datetime().millisecond); float randinterval = nextfloat(random); int dropspeed = random.next(1, 7); _mslist.add(new matrixstring(chinese, randinterval, dropspeed, dropspeed, 1.0f, xoff, 10)); xoff = * 32; }

you need create random instance outside for loop:

random random = new random(new system.datetime().millisecond); (int = 0; < (wwidth / 30); i++) { float randinterval = nextfloat(random); int dropspeed = random.next(1, 7); _mslist.add(new matrixstring( chinese, randinterval, dropspeed, dropspeed, 1.0f, xoff, 10)); xoff = * 32; }

within short running loop, seeding new system.datetime().millisecond create same seed value. hence, same random number.

c# random xna

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -