Example #1
0
        //pomocna funkcija za jest
        private void Eat(Food food, Vector2 NewHeadPosition)
        {
            CurrentFoodUnit = Food.CreateNewFoodUnit();

            //if the food spawned on the snake, spawn it again
            while (BodyParts.Contains(CurrentFoodUnit.Location()) ||
                   HeadPosition == CurrentFoodUnit.Location() ||
                   NewHeadPosition == CurrentFoodUnit.Location())
            {
                CurrentFoodUnit = Food.CreateNewFoodUnit();
            }

            //increase time left before starvation
            timeLeft += 100;

            //ALL HAIL MAGIC NUMBERS!!!!
            if (isTested || length > 10)
            {
                TimesToGrow += 4;
            }
            else
            {
                TimesToGrow += 1;
            }
        }