Jump to content
  • Advertisement
Sign in to follow this  
RebornCrosis

Question about Counter controlled repetition

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!