I program movement of XONIX
view through an array of parameters and coordinates
and main thing is that it is unclear: how to set colors
avoiding names of colors like "Red"?
Now
As less than
Plus if I set "int w=400, h=300;" window size:
"Width = w; Height = h;"
how to transfer variables to flight boundaries?
Run: inside
C:\Windows\Microsoft.NET\Framework64\v4.0.30319
xonixmult.bat
csc.exe /target:winexe xonixmult.cs
pause
120 kB
view through an array of parameters and coordinates
and main thing is that it is unclear: how to set colors
avoiding names of colors like "Red"?
Now
C#:
dav.DrawEllipse(new Pen(Color.Red, 12),x[i],y[i],f[i],f[i]);
As less than
C#:
dav.DrawEllipse(new Pen(Color.FromArgb(0,0,255,0),12), x[i]-dx[i],y[i]-dy[i],f[i],f[i]);
Plus if I set "int w=400, h=300;" window size:
"Width = w; Height = h;"
how to transfer variables to flight boundaries?
Run: inside
C:\Windows\Microsoft.NET\Framework64\v4.0.30319
xonixmult.bat
csc.exe /target:winexe xonixmult.cs
pause
C#:
using System; using System.Drawing; // xonixmult.cs
using System.Windows.Forms; class xonix: Form
{ public static void Main()
{ Application.Run(new xonix());}
public xonix()
{ Text = "XONIX"; int w=400, h=300;
BackColor = System.Drawing.Color.Blue;
ForeColor = System.Drawing.Color.Magenta;
ResizeRedraw = true; Width = w; Height = h;
}
protected override void OnPaint(PaintEventArgs and)
{ Graphics dav = and.Graphics; int n=13, a=380, b=240;
Random rand = new Random(); int[] f = new int[n];
int[] x = new int[n]; int[] y = new int[n];
int[] dx = new int[n]; int[] dy = new int[n];
int[] c = new int[n];
for (int i=1; i<n; i++)
{ f[i] = (2+rand.Next(3))*5; c[i] = 1+rand.Next(3);
x[i] = rand.Next(a); y[i] = rand.Next(b);
dx[i] = rand.Next(5)-2; dy[i] = rand.Next(5)-3;
}
for (int k=1; k <700; k++)
for (int i=1; i<n; i++)
{ dav.DrawEllipse(new Pen(Color.Green,12), x[i]-dx[i],y[i]-dy[i],f[i],f[i]);
if (1==c[i]) dav.DrawEllipse(new Pen(Color.Magenta, 12),x[i],y[i],f[i],f[i]);
if (2==c[i]) dav.DrawEllipse(new Pen(Color.Yellow, 12),x[i],y[i],f[i],f[i]);
if (3==c[i]) dav.DrawEllipse(new Pen(Color.Red, 12),x[i],y[i],f[i],f[i]);
System.Threading.Thread.Sleep(1);
if ((x[i] + dx[i] < 1) || (x[i] + dx[i] > a)) dx[i] = -dx[i];
if ((y[i] + dy[i] < 1) || (y[i] + dy[i] > b)) dy[i] = -dy[i];
x[i] += dx[i]; y[i] += dy[i];
}}}
// dav.DrawEllipse(new Pen(Color.FromArgb(0,0,255,0),12), x[i]-dx[i],y[i]-dy[i],f[i],f[i]);