I am having trouble finding of a way to go about creating an equation inside my for loop that will generate a number of objects in a List collectibleList
depending on the level that the character is on. As it is now, my list only creates one collectible
per level. This, I'm guessing, is because of the i < currentLevel
bound. But I don't know what kind of bound I should use or how to implement i
in an equation so that more collectibles
can be added to my list depending on the currentLevel
.
// Set up each level the player encounters
public void NextLevel()
{
collectibleList.Clear();
currentLevel++;
timer = 10;
player.LevelScore = 0;
player.Position = new Rectangle(GraphicsDevice.Viewport.Width/2, GraphicsDevice.Viewport.Height/2, player.Position.Width, player.Position.Height);
// Random number generator that will help generate a random position of the collectible sprite
Random rng = new Random();
for (int i = 0; i < currentLevel; i++)
{
Collectible collectible = new Collectible(rng.Next(0, GraphicsDevice.Viewport.Width), rng.Next(0, GraphicsDevice.Viewport.Height), 70, 91, true);
collectible.ObjectSprite = collectibleSprite;
collectibleList.Add(collectible);
}
}