Example #1
0
 private void leTemps_Tick(object sender, EventArgs e)
 {
     laPieceSerpent.leGraphique.Clear(Color.White);
     this.Text = score.ToString();
     laPieceSerpent.leGraphique.FillRectangle(
         new SolidBrush(Color.Red),
         proie.X * laPieceSerpent.tailleX,
         proie.Y * laPieceSerpent.tailleY,
         laPieceSerpent.tailleX,
         laPieceSerpent.tailleY);
     laTete = new laPieceSerpent()
     {
         coordonnees =
             new Point((laTete.coordonnees.X + nx +
                        laPieceSerpent.tailleDuJeu) % laPieceSerpent.tailleDuJeu,
                       (laTete.coordonnees.Y + ny +
                        laPieceSerpent.tailleDuJeu) % laPieceSerpent.tailleDuJeu),
         PiecePrecedente = laTete
     };
     if (laTete.coordonnees.Equals(proie))
     {
         score++;
         proie = new Point(new System.Random().Next(laPieceSerpent.tailleDuJeu),
                           new System.Random().Next(laPieceSerpent.tailleDuJeu));
     }
     laTete.diminution(score);
     laTete.PiecePrecedente.BitItSelf(laTete.coordonnees);
 }
Example #2
0
 public void diminution(int length)
 {
     if (length-- <= 0)
     {
         PiecePrecedente = null; return;
     }
     PiecePrecedente.diminution(length);
     leGraphique.FillRectangle(new SolidBrush(Color.Blue),
                               coordonnees.X * tailleX, coordonnees.Y * tailleY, tailleX, tailleY);
 }