I have no idea what for loops are.. Can someone explain to me what for loops are and what they are used for? Also, can you give me other different types of loops?
for (int i=0; i<lives; i++) addObject(new Life(), 50+i*30, 50);
public void adjustlives(int amount)
{
lives += amount;
removeObjects(getObjects(Life.class));
for (int i=0; i<lives; i++) addObject(new Life(), 50+i*30, 50);
}adjustLives(3);
if (player.getWorld() != this)
{
adjustLives(-1);
if (lives < 0) gameOver(); else resetLevel();
}public class level1 extends levels
{
int lives;
private static final int GAP = 30; // This will allow a specific gap between each 'Person'
private void createRows()
{
int y = 80; // This is the location the row will start from in the world from the y axis
while(y <= 700) // This is to adjust how many rows of people will there be in the world
{
createRows(y); // This is to create how many row of person you want depending on the y axis
y = y + 240 + GAP; // This is the calculation for the spaces between each Persons in the World
}
}
private void createRows(int y)
{
int x = 50; // This is the location the row will start from in the world from the x axis
while(x < 900) // if the ‘x’ are less than or equal to 900
{
addObject (new person(), x, y); // A new Person will be created at the coordinated that has been created at
x = x + 150 + GAP; // This is the calculation for the spaces between each row of people in the World
}
}
public void adjustlives(int amount)
{
lives += amount;
removeObjects(getObjects(HealthBar.class));
for (int i=0; i<lives; i++) addObject(new HealthBar(), 50+i*30, 50);
}public void adjustLives(int amount)
public level1()