Skip to main content

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

nichols_j | Aus

2
Posts
A member registered Sep 05, 2017

Recent community posts

(1 edit)

Bug: Nested "for x times loops" not working

Basically, next nested for x times loops don't work as you'd expect in decent for-loop coding, as if the increment variable is shared between the two.

Likely culprit: When the exterior loop loops once, the 'loop count' is set to whatever loop count is the first one, but said value is overwritten by for x times loop(s) within said for loop, either leading to a bodged forever loop or a loop 1 times loop as the exterior loop.

Java example:

//Java "loop forever" for loop example
for (int i = 0; i < 10; i++) {
  for (int i = 0; i < 6; i++) {
    //The variable i is overwritten, reaches 6 and then the main loop is run again, and again, etc.
    do(x);
  }
}
//Java "loop for 1 times" for loop example
for (int i = 0; i < 10; i++) {
  for (int i = 0; i < 12; i++) {
    //The variable I is overwritten, reaches 12 and then the main loop is skipped
    do(x);
  }
}

Hope the description and possible reason helps; I don't know very much C, but Java is a close-enough language for it to be fairly easily translatable into C.

When you hover over the name and finish building the popup info doesn't go away until you save, quit and load.

(╯°□°)╯︵ ┻━┻