Beispiel #1
0
 public void Initialize()
 {
     foreach (Cell c in body)
     {
         engine.AddObject(c);
     }
 }
 public void Initialize(GameEngine engine)
 {
     for (int y = Y; y < HeightActive; y += Cell.Size)
     {
         for (int x = X; x < WidthActive; x += Cell.Size)
         {
             engine.AddObject(new Cell(x, y, Color.ForegroundColor));   // Draw decorative filling of the background
         }
     }
 }
Beispiel #3
0
 public void Eat(Food food, GameEngine engine)
 {
     if ((body.First().X == food.X) && (body.First().Y == food.Y))
     {
         body.Insert(0, new Cell(food.X, food.Y, color));
         FoodEated++;
         food.CanCreateNext = true;
         do
         {
             food.CreateNext();
             foreach (var c in body)
             {
                 if (food.X == c.X && food.Y == c.Y)
                 {
                     food.CanCreateNext = true;          // food can't appear on the snake body
                     break;
                 }
             }
         } while (food.CanCreateNext);
         engine.AddObject(body.First());
     }
 }