Facebook Sayfamızı Beğenin

11 Mart 2016 Cuma

Araba Yarışı

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//Başla buton yazılacak kodlar:
 
timer1.Enabled = true;
 
//Program içeriği ve olayın geçtiği yer timer dır .
 
//Zaman artıkça Pictureboxlar hareket edecekler
 
//Timer1 yazılacak kodlar şunlardır ;
private void timer1_Tick(object sender, EventArgs e)
{
if (pictureBox1.Right <= panel1.Left && pictureBox2.Right <= panel1.Left && pictureBox3.Right <= panel1.Left && pictureBox4.Right <= panel1.Left)
 
{
Random r1 = new Random(); // random ile değişkenler
 
int i = 0;
int[] resim = new int[5];  // değişkenimiz 5 kadar
 
for (i = 0; i <= 4; i++)  // for döngüsü sokuyoruz
 
{
resim[i] = r1.Next(1, 15); // resimlerin hareketi
 
}
pictureBox1.Left = pictureBox1.Left + resim[0];
pictureBox2.Left = pictureBox1.Left + resim[1];
pictureBox3.Left = pictureBox1.Left + resim[2];
pictureBox4.Left = pictureBox1.Left + resim[3];
 
}
else
{
timer1.Enabled =false;
 
}
 
}

Hiç yorum yok:

Yorum Gönder