Hello guys. I made an orbit ( circle ) and a ball. I built the code , like the ball to move on the orbit. But i have a problem with the orbit , because it flash. Is there any option like the orbit to don't flash ?
Here's the source code:
private void Form1_Paint(object sender, PaintEventArgs e)
{
SolidBrush redBrush = new SolidBrush(Color.RoyalBlue);
SolidBrush black = new SolidBrush(Color.Black);
float x0;
float y0;
int k;
double pi = Math.PI, pas = pi / 18;
int n = 2;
double u = (2 * pi) / n;
n = 1;
u = (2 * pi) / n;
while (true)
{
e.Graphics.DrawEllipse(Pens.AliceBlue, 50, 50, 200, 200);
x0 = 144 + 100 * (float)Math.Cos(u);
y0 = 144 + 100 * (float)Math.Sin(u);
e.Graphics.FillEllipse(redBrush, x0, y0, 12, 12);
Thread.Sleep(50);
//===============================================
e.Graphics.DrawEllipse(Pens.Black, 50, 50, 200, 200);
x0 = 144 + 100 * (float)Math.Cos(u);
y0 = 144 + 100 * (float)Math.Sin(u);
e.Graphics.FillEllipse(black, x0, y0, 12, 12);
Thread.Sleep(2);
u = u + pas;
if (u >= 2*pi) u = 0;
}
}
Here is the application:
http://www.2shared.com/file/12790047/e0d291ac/Elipse_C_Sharp_.html