• 11
• 9
• 12
• 9
• 11

# Question about Counter controlled repetition

This topic is 4616 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Ok In the book I am reading I just got to while repeptiton, I under stand While repitition strucutre. I am geting stuck on Counter controlled repetition Strucutre. I was wondering do alot of rpgs use counter controlled reptition Strucutres. Casue Even though it is kinda of tricky I am going to keep doing it until I understand it very good. I was just wondering what could you do with it in a rpg.

##### Share on other sites
A simplistic example:

struct   character{       int    action_points;       void   attack();       void   continuous_attack(){                 while ( action_points > 0 ){                     attack();                     action_points--;             }       }};

Let me know if that doesn't seem to be your counter controlled structure, and what the book shows as that structure if it doesn't.

##### Share on other sites
in the early days, things like this we're common:

// assuming I had some array of things and a variable numObjects// that told me how many items I had put in it.for(int i=0; i<numObjects; ++i)  {  // do stuff here ... below is a fairly silly example  std::cout << "object[" << i << "] = " << objects << std::endl;  }

and you would use a technique like that to do things like make every item in the list move, or do whatever ... very popular ... of course in modern C++ you would use a standard container object to do these things, but you still need to understand basic counter loop structures to do much programming.

##### Share on other sites
Ok I understand alittle but better, A while counter controlled repitition is just a while repition with a counter add one it it. So it is more in depth of programe with a while repitition sturce. p/s How do u do the box thing where u put ur code.

##### Share on other sites
use:

[ s o u r c e ]

and

[ / s o u r c e ]

boxes, without the spaces