private void CreateLabel() { particles p = new particles(); Label label = new Label(); string[] dirs = { "RU", "RD", "LU", "LD" }; string dir; Random random = new Random(); int k = random.Next(0, 3); dir = dirs[k]; int x = random.Next(0, Width - 50); int y = random.Next(0, Height - 50); Point point = new Point(x, y); label.Location = point; label.Text = aa + ""; aa++; label.Font = new Font("Times New Roman", 11.25F, FontStyle.Bold, GraphicsUnit.Point, 204); label.Width = 13; label.Height = 15; label.BackColor = Color.Black; label.ForeColor = Color.White; p.label = label; p.dir = dir; labels.Add(p); Controls.Add(label); }
private particles Changedir(particles p) { if (p.label.Location.X <= 10) { if (p.dir == "LU") { p.dir = "RU"; } if (p.dir == "LD") { p.dir = "RD"; } } if (p.label.Location.X >= Width - 40) { if (p.dir == "RU") { p.dir = "LU"; } if (p.dir == "RD") { p.dir = "LD"; } } if (p.label.Location.Y <= 10) { if (p.dir == "RU") { p.dir = "RD"; } if (p.dir == "LU") { p.dir = "LD"; } } if (p.label.Location.Y >= Height - 70) { if (p.dir == "LD") { p.dir = "LU"; } if (p.dir == "RD") { p.dir = "RU"; } } return(p); }