i need help with some "scary" thing.
I'm creating some objects in foreach loop. Each object has implemented in Update function random change of position.
But while i'm creating this objects in foreach loop, each object gets the same random position, and i don't know why. Please help me.
For better explanation:
objects = new List<Object>(); objects.Add(new Object()); objects.Add(new Object()); objects.Add(new Object());
and Update and Draw function:
foreach(var obj in objects) obj.Update(); // obj.Draw();
in Object Update function:
Position.X = rand.Next(width); Position.Y = rand.Next(height);
The problem comming in launched game, where I can see only one object, instead of three. All that objects has same position, so they are covered by each other.