- 5 Şub 2022
- 606
- 90
Merhaba ben tılnınca lokasyanu rastgele değişen bir buton yaptım
ama
ben bu butonun aynı zamanda tıklanmayıncada okasyonunun değişmesini istiyorum
bunu nası yaabilirim?
KOD:
ama
ben bu butonun aynı zamanda tıklanmayıncada okasyonunun değişmesini istiyorum
bunu nası yaabilirim?
KOD:
C#:
using System;
private void button1_Click(object sender, EventArgs e)
{
puan.Visible = true;
Random rnd = new Random();
int secilen1 = rnd.Next(100, 400);
int secilen2 = rnd.Next(100, 400);
int secilen3 = rnd.Next(100, 300);
int secilen4 = rnd.Next(100, 300);
button1.Location = new Point(secilen1, secilen2);
sayi = sayi + 1;
puan.Text = "PUAN = " + sayi.ToString();
Color[] renkler = new Color[9] {Color.Red, Color.Green, Color.Blue, Color.Black, Color.Brown,
Color.Pink, Color.Purple, Color.Yellow, Color.White};
Random x = new Random();
Random y = new Random();
int renk = x.Next(0, 9);
this.BackColor = renkler[renk];
Color[] rrenkler = new Color[9] {Color.Red, Color.Green, Color.Blue, Color.Black, Color.Brown,
Color.Pink, Color.Purple, Color.Yellow, Color.White};
int PuanRengi = y.Next(0, 9);
this.puan.ForeColor = rrenkler[PuanRengi];
timer1.Interval = 1000;
timer1.Enabled = true;
}
private void timer1_Tick(object sender, EventArgs e)
{
if (zaman >= 0)
{
Color[] renkler = new Color[9] {Color.Red, Color.Green, Color.Blue, Color.Black, Color.Brown,
Color.Pink, Color.Purple, Color.Yellow, Color.White};
Random x = new Random();
int renk = x.Next(0, 9);
this.time.ForeColor = renkler[renk];
timer1.Interval = 1000;
timer1.Enabled = true;
int sayac = zaman--;
time.Text = sayac.ToString();
timer1.Interval = 1000;
timer1.Enabled = true;
}
if (zaman <= 0)
{
label2.Text = puan.Text.ToString();
label1.Visible = true;
label2.Visible = true;
time.Visible = false;
puan.Visible = false;
button1.Visible = false;
}
}
}
}