The algorithm is quite simple. You can see it in the code below:
Code:
foreach (Stick stick in sticks)
{
spriteBatch.Draw(pixelTex, stick.Rect, null, stick.Col,
stick.Rot, Vector2.Zero, SpriteEffects.None, 0.5f);
}
where:
pixelTex is a white texture of 1x1 pixel
stick.Rect is a thin rectangle of a given length
stick.Col is the color of the stick
stick.Rot is the angle of the stick
In the Update method, for each update, a stick is created and is added to the list. The creation will stop once the stop flag is signalled. The stop flag is shown below:
Code:
double frate = 1 / gameTime.ElapsedGameTime.TotalSeconds;
int frameRate = Convert.ToInt32(frate);
if (frameRate < 30)
stopFlag = true;
Both codes are in the Draw method.
However, I noticed the frame rate in the display is sometimes flicky when the number of sticks reaches to the final value. I am going to add a running average routine for the frame rate to remove unwanted glitches.
I will start a thread for the demo once I finish my experiment.
Any suggestion is welcome.