Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

A for loop is executed like so:

  1. Execute the first expression. In this case that declares a variable called i and sets its value to one.
  2. Execute the second expression. If it evaluates to true, jump to the inside of the loop.
  3. After the body of the loop has completed, execute the final expression. In this case that adds one to i.
  4. Jump back to step 2 and rinse and repeat until the second expression evaluates to false.

In short, all a foo loop does is iterate until the second expression evaluates to false (in this case, if i is greater than or equal to 100), which is in this case caused by adding one onto i.

(+1)

ah thanks for the explanation, i understand how they work now.