private void button1_Click(object sender, EventArgs e) { Graphics g = this.panel1.CreateGraphics(); thucan = new ThucAn(); thucan.TyLe = 50; thucan.X = (int)(this.panel1.Width / thucan.TyLe); thucan.Y = (int)(this.panel1.Height / thucan.TyLe); thucan.g = g; thucan.VeThucAn(false); g.Dispose(); }
private void TaoThucAn() { thucan = new ThucAn(); thucan.TyLe = snack.TyLe; Random rnd = new Random(); int x = rnd.Next((int)(this.panel1.Width / thucan.TyLe)); int y = rnd.Next((int)(this.panel1.Height / thucan.TyLe)); thucan.X = x; thucan.Y = y; thucan.g = g; thucan.VeThucAn(false); }