I trying to make a platform game I need to add loops. Can people give me examples of how to integrate loops in a platform game.
int sum = 0; // initial sum field
for (int index = 1; index <= 10; index++)
{
sum += index; // add the number 'index' holds to the sum field
}int sum = 0; // initial sum field
for (int index = 1; index <= 10; index++)
{
sum += index; // add the number 'index' holds to the sum field
}int sum = 0; // initial sum field
for (int index = 1; index <= 10; index++)
{
sum += index; // add the number 'index' holds to the sum field
}Actor nearestTop = null; // to hold the closest object found so far (if any)
for (Object obj : getObjects(null)) // for each object (actor) in the world
{
Actor actor = (Actor)obj; // cast object to Actor
if (nearestTop == null || nearestTop.getY() > actor.getY())
{ // if we do not yet have an actor held as close or if the actor held as close is not as close as this actor from the list
nearestTop = actor; // hold this actor from the list
}
}