Form üzerinde atların rastgele hızla ilerlemesini ve bitişe ilk ulaşanını messagebox ile gösteren basit bir uygulama.
Kod:
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;[/COLOR]
[COLOR=#111111]namespace AT_YARIŞI
{
public partial class Form1 : Form
{
int uzaklık1, uzaklık2, uzaklık3;
Random rastgelesayi = new Random();
public Form1()
{
InitializeComponent();
}
[/COLOR]
[COLOR=#111111]
private void Form1_Load(object sender, EventArgs e)
{
uzaklık1 = pictureBox1.Left;
uzaklık2 = pictureBox2.Left;
uzaklık3 = pictureBox3.Left;
}
private void button1_Click(object sender, EventArgs e)
{
if (timer1.Enabled == false)
{
timer1.Start();
}
[/COLOR]
[COLOR=#111111]else
{
timer1.Stop();
}
}
[/COLOR]