20 Mart 2015 Cuma

C # Kolay Araba Yarışı



KOD KISMI


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {

        Random a = new Random();
        int x1, x2, x3;
        public Form1()
        {
            InitializeComponent();
        }

        private void pictureBox8_Click(object sender, EventArgs e)
        {
            timer1.Start();
            timer2.Start();
            timer3.Start();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            x1 = x1 + 2;
            pictureBox9.Location = new Point(x1, 60);

            if (x1 == 400)
            {
                timer1.Stop();
                listBox1.Items.Add("porsche");
            }
        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {

        }

        private void Form1_Load(object sender, EventArgs e)
        {
            this.Text = "ARABA YARIŞI";
            int r1 = a.Next(5, 50);
            int r2 = a.Next(5, 50);
            int r3 = a.Next(5, 50);

            timer1.Interval = r1;
            timer2.Interval = r2;
            timer3.Interval = r3;

          
        }

        private void timer2_Tick(object sender, EventArgs e)
        {
            x2 = x2 + 2;
            pictureBox10.Location = new Point(x2, 230);

            if (x2 == 400)
            {
                timer2.Stop();
                listBox1.Items.Add("bmw");
            }
        }

        private void timer3_Tick(object sender, EventArgs e)
        {
            x3 = x3 + 2;
            pictureBox11.Location = new Point(x3, 388);

            if (x3 == 400)
            {
                timer3.Stop();
                listBox1.Items.Add("ferrari");
            }
        }


ONUR TAŞKIN

Hiç yorum yok: