Esempio n. 1
0
        public void GenerateApple()
        {
            Random rnd = new Random();
            int    x   = 0;
            int    y   = 0;

            while (true)
            {
                x = rnd.Next(0, GameField.GetRectanglesOnWidth());
                y = rnd.Next(0, GameField.GetRectanglesOnHeight());

                if (GetGameInfo(x, y) == GameInfo.NaN)
                {
                    break;
                }
            }

            GameField.gameField[x, y].SetToApple();
        }
Esempio n. 2
0
        public void GenerateSnail()
        {
            Random rnd = new Random();
            int    x   = 0;
            int    y   = 0;

            while (true)
            {
                x = rnd.Next(0, GameField.GetRectanglesOnWidth());
                y = rnd.Next(0, GameField.GetRectanglesOnHeight());

                if (GetGameInfo(x, y) == GameInfo.NaN)
                {
                    break;
                }
            }

            Snail = new Snail();
            Snail.SetPosition(x, y);
            GameField.gameField[Snail.Place.X, Snail.Place.Y].SetToSnail();
        }