Exemple #1
0
 private void Form1_Load(object sender, EventArgs e)
 {
     for (int i = 0; i < 5; i++)
     {
         hors[i]      = new horse();
         hors[i].name = String.Format("Horse number {0}", i + 1);
     }
     hors[0].picture  = picBox_horse1;
     hors[0].startLoc = picBox_horse1.Location;
     hors[1].picture  = picBox_horse2;
     hors[1].startLoc = picBox_horse2.Location;
     hors[2].picture  = picBox_horse3;
     hors[2].startLoc = picBox_horse3.Location;
     hors[3].picture  = picBox_horse4;
     hors[3].startLoc = picBox_horse4.Location;
     hors[4].picture  = picBox_horse5;
     hors[4].startLoc = picBox_horse5.Location;
     for (int i = 0; i < horseNum; i++)
     {
         hors[i].IsInRace = true;
     }
 }
Exemple #2
0
        private void CalScore()
        {
            horse tmp = new horse();

            scoreBoard.AppendText("Scores\r\n");
            for (int i = 0; i < horseNum; i++)
            {
                for (int ii = i + 1; ii < horseNum; ii++)
                {
                    if (hors[i].picture.Left < hors[ii].picture.Left)
                    {
                        tmp      = hors[i];
                        hors[i]  = hors[ii];
                        hors[ii] = tmp;
                    }
                }
            }
            hors[0].score = 50;
            hors[1].score = 40;
            for (int i = 0; i < 2; i++)
            {
                scoreBoard.AppendText(String.Format("{0}: {1}\r\n", hors[i].name, hors[i].score));
            }
        }