public SnakeObjects.SnakeFood GenerateFood() { SnakeFood result = new SnakeFood(75); result.RemainingTime = 5; result.Texture = Content.Load<Texture2D>("cherry"); return result; }
private void GenerateSnakeFood(GameTime gameTime) { if (foodElapsedTime < 0) { if (FoodCount < FoodCap) { foodElapsedTime = 0; Random randX = new Random(DateTime.Now.Millisecond); Random randY = new Random(DateTime.Now.Millisecond + 5); int xPos, yPos; xPos = randX.Next(0, Width - 1); yPos = randY.Next(0, Height - 1); if (!cellsInUse.Contains(Cells[yPos * Width + xPos])) { FoodCount++; pickUp = SnakeFoodFactory.CreateFromTemplate("cherry"); pickUp.Position = new Point(xPos, yPos); //pickUp.Texture = mapDrops.Add(pickUp); Cells[yPos * Width + xPos].Pickup = pickUp; foodElapsedTime = randomDropTime.Next(1, 3000); } } } else { foodElapsedTime -= gameTime.ElapsedGameTime.TotalMilliseconds; } }