private void button1_Click(object sender, EventArgs e) { /* while clicking on the race button all timer will be start to do the task * while passing the interval also to change the speed of the cars */ TmCar1.Start(); TmCar1.Interval = rnd.Next(1, 15); tmCar2.Start(); tmCar2.Interval = rnd.Next(1, 7); tmCar3.Start(); tmCar3.Interval = rnd.Next(1, 10); btnRace.Enabled = false; }
private void tmCar3_Tick(object sender, EventArgs e) { // this task perform the movement of the picture just when the pictureis less than the ending point if (Car3.Left <= 570) { Car3.Left += objCar.position(); } else { tmCar3.Stop(); } // when car reached at the ending point then the winning dialogue box will be appear if (Car3.Left >= 570) { winner = 3; tmCar2.Stop(); tmCar3.Stop(); TmCar1.Stop(); MessageBox.Show("Car 3 is winner"); winningPlayer(); } }