Beispiel #1
0
        void CheckFood()
        {
            if (w.CheckCollision(b.body))
            {
                gameOver = true;
                Console.Clear();
                Console.SetCursorPosition(10, 20);
                Console.WriteLine("Game over!");
            }
            else if (w.CheckCollision(f.body))
            {
                w.Eat(f.body[0]);
                score++;
                f.Generate();
            }
            else if (w.CheckCollisionwithItself())
            {
                gameOver = true;
                Console.Clear();
                Console.SetCursorPosition(10, 20);
                Console.WriteLine("Game over!");
            }

            if (score > MaxScore)
            {
                b.Clear();
                b.body.Clear();
                level = 3;
                b.LoadLevel(3);
            }
        }
Beispiel #2
0
        private void CheckCollision()
        {
            if (worm.IsIntersected(wall.body) || worm.IsIntersected(worm.body))
            {
                gameOver = true;
                Console.Clear();
                Console.SetCursorPosition(15, 20);
                Console.Write("Game Over!");
            }
            else if (worm.IsIntersected(food.body))
            {
                //player.score.Score += 10;
                scoreLevel.Score += 25;
                player.Score      = scoreLevel.Score;
                if (scoreLevel.Score == 50)
                {
                    wall.Clear();
                    LevelNumber      = 1;
                    scoreLevel.Level = 2;
                    wall.Draw();
                }
                else if (scoreLevel.Score == 100)
                {
                    wall.Clear();

                    LevelNumber      = 2;
                    scoreLevel.Level = 3;
                    wall             = new Wall('#', LevelNumber);
                    wall.Draw();
                }
                worm.Eat(food.body);
                food.GenerateLocation(worm.body, wall.body);
            }
        }
Beispiel #3
0
 public void CheckCollision()
 {
     if (worm.IsIntersected(wall.body) || worm.CheckWall())
     {
         timer.Enabled = false;
         Console.Clear();
         Console.SetCursorPosition(15, 20);
         Console.Write("Game over!");
     }
     else if (worm.IsIntersected(food.body))
     {
         score++;
         if (score == 2)
         {
             degree++;
         }
         if (score == 5)
         {
             degree++;
         }
         Console.SetCursorPosition(41, 1);
         Console.WriteLine("Your score: " + score);
         Console.SetCursorPosition(41, 2);
         Console.WriteLine("Level: " + degree);
         worm.Eat(food.body);
         Thread.Sleep(200 - score);
         food.GenerateLocation(worm.body, wall.body);
         food.Draw();
     }
 }
Beispiel #4
0
 void CheckFood()
 {
     if (w.CheckCollision(f.body[0]))
     {
         eating = true;
         w.Eat(f.body[0]);
         Bally.Score += 10;
         f.Generate();
         foreach (Point p in b.body)
         {
             if (f.body[0].X == p.X && f.body[0].Y == p.Y)
             {
                 f.Generate();
                 f.Draw();
             }
         }
         foreach (Point p in w.body)
         {
             if (p.X == f.body[0].X && p.Y == f.body[0].Y && !eating)
             {
                 f.Generate();
                 f.Draw();
             }
         }
         eating = false;
     }
 }
Beispiel #5
0
 void CheckColision()
 {
     if (worm.CheckIntersection(food.body) == true)
     {
         worm.Eat(food.body);
         food.Generate();
     }
 }
Beispiel #6
0
 public void CheckCollision()
 {
     if (worm.CheckIntersection(food.body[0]))
     {
         worm.Eat(food.body[0]);
         food.Generate();
     }
 }
Beispiel #7
0
 void CheckFood()
 {
     if (w.CheckCollision(f.body[0]))
     {
         w.Eat(f.body[0]);
         f.Generate();
     }
 }
Beispiel #8
0
 public void CheckFood()
 {
     if (w.CheckCollision(f.body[0]))
     {
         w.Eat(f.body[0]);
         Generate();
         score++;
         Score(score);
     }
 }
Beispiel #9
0
 public void CheckCollision()
 {
     if (worm.CheckIntersection(food.body))
     {
         worm.Eat(food.body);
         food.Generate();
     }
     if (worm.CheckIntersection(wall.body))
     {
         //GameOver = true;
     }
 }
Beispiel #10
0
        public void MoveSnake()
        {
            while (anal)
            {
                worm.Clear();

                worm.Move();
                worm.Draw();
                ShowStatusBar(worm.body.Count.ToString());
                //worm.Draw();

                //CheckCollision();
                if (worm.IsIntersected(wall.body))
                {
                    Console.Clear();
                    Console.SetCursorPosition(15, 20);
                    Console.Write("Game over!");
                    anal = false;
                }
                if (worm.IsIntersected(food.body))
                {
                    anal = true;
                    worm.Eat(food.body);
                    food.GenerateLocation(worm.body, wall.body);
                    food.Draw();
                }
                else if (worm.snakegavno(worm.body))
                {
                    Console.Clear();
                    Console.SetCursorPosition(15, 20);
                    Console.Write("Game over!");
                    anal = false;
                }
                if ((Convert.ToInt32(worm.body.Count.ToString()) >= 1 && (Convert.ToInt32(worm.body.Count.ToString()) <= 3)))
                {
                    Thread.Sleep(150);
                }
                else if ((Convert.ToInt32(worm.body.Count.ToString()) >= 4 && (Convert.ToInt32(worm.body.Count.ToString()) <= 7)))
                {
                    Thread.Sleep(100);
                }
                else if ((Convert.ToInt32(worm.body.Count.ToString()) >= 8 && (Convert.ToInt32(worm.body.Count.ToString()) <= 10)))
                {
                    Thread.Sleep(50);
                }
                else if ((Convert.ToInt32(worm.body.Count.ToString()) >= 11))
                {
                    Thread.Sleep(10);
                }
            }
        }
Beispiel #11
0
 private void CheckCollision()
 {
     if (worm.IsIntersected(wall.body))
     {
         gameOver = true;
         Console.Clear();
         Console.SetCursorPosition(10, 20);
         Console.Write("Game over!");
     }
     else if (worm.IsIntersected(food.body))
     {
         worm.Eat(food.body);
         food.GenerateLocation();
     }
 }
Beispiel #12
0
 private void CheckCollision()
 {
     if (worm.IsIntersected(wall.body))
     {
         timer.Enabled = false;
         Console.Clear();
         Console.SetCursorPosition(10, 20);
         Console.Write("Game over!");
     }
     else if (worm.IsIntersected(food.body))
     {
         worm.Eat(food.body);
         food.GenerateLocation(worm.body, wall.body);
         food.Draw();
     }
 }
Beispiel #13
0
 void CheckFood()
 {
     if (w.CheckCollision(f.body[0]))
     {
         score++;
         if (score == 2)
         {
             degree++;
         }
         if (score == 5)
         {
             degree++;
         }
         w.Eat(f.body[0]);
         f.Generate();
     }
 }
Beispiel #14
0
 private void CheckCollision()
 {
     if (worm.IsIntersected2()) /////////WORM BODY COLLISION
     {
         Butter.gameOver = true;
         gameover();
     }
     else
     if (worm.IsIntersected(wall.body))/////////WORM WALL COLLISION
     {
         Butter.gameOver = true;
         gameover();
     }
     else if (worm.IsIntersected(food.body))
     {
         worm.Eat(food.body);
         food.GenerateLocation();
         food.Draw();
     }
 }
Beispiel #15
0
 void CheckFood()
 {
     if (w.CheckCollision(f.body[0]))
     {
         point += 100 + level * 10;
         w.Eat(f.body[0]);
         if (point >= levels[level])
         {
             level++;
             speed -= 50;
             b.LoadLevel(level);
             Console.BackgroundColor = ConsoleColor.Gray;
             b.Draw();
             Console.BackgroundColor = ConsoleColor.Black;
         }
         f.Generate(new object[] { w, b });
         Console.ForegroundColor = ConsoleColor.Red;
         f.Draw();
         Console.ForegroundColor = ConsoleColor.Green;
     }
 }