Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17560

Clever function call? (c++)

$
0
0

Hi!

Any way to write a function in C++ so i could replace the below:

 for (int i = 0; i < MAX_BLOCK; i++)
 for (int ii = 0; ii < MAX_BLOCK; ii++)
  for (int iii = 0; iii < BUILDING_X; iii++)
   for (int iiii = 0; iiii < BUILDING_Y; iiii++){
      block[i][ii].building[iii][iiii].doSomething();
}

with something like this (i access every building but can change what to do with them in the “body” like i do below).

doEveryBuilding(){
  b.doSomething();
}

Viewing all articles
Browse latest Browse all 17560

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>