Example #1
0
 private void gameOver()
 {
     this.FormBorderStyle = FormBorderStyle.Sizable;
     timer.Stop();
     dirX = 0; dirY = 0;
     restartButton.Enabled = true;
     restartButton.Focus();
     recordsButton.Enabled = true;
     menuButton.Enabled    = true;
     this.ActiveControl    = restartButton;
     record = new SaveRecord(score, false);
     record.ShowDialog();
 }
Example #2
0
 private void eatFruit()
 {
     if (snake[0].Location == fruit.Location)
     {
         switch (fruit.Name)
         {
         case "wine":
             wineEaten = true;
             wineTime  = timerInterval * 10;
             break;
         }
         labelScore.Text = "Score: " + ++score;
         snake.Add(new PictureBox());
         snake[score].Size   = new Size(sizeOfBlocks, sizeOfBlocks);
         snake[score].Anchor = AnchorStyles.None;
         snake[score].Image  = fruit.Image;
         this.Controls.Add(snake[score]);
         if (score != endScore)
         {
             generateFruit();
         }
         else
         {
             record = new SaveRecord(score, false);
             record.ShowDialog();
         }
     }
     else if (snake[0].Location == lemon.Location)
     {
         if (score > 0)
         {
             labelScore.Text = "Score: " + --score;
             this.Controls.Remove(snake[snake.Count - 1]);
             snake.RemoveAt(snake.Count - 1);
             generateLemon();
         }
         else
         {
             gameOver();
         }
     }
 }