🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

What does this mean?

Started by
2 comments, last by Zombie 24 years, 6 months ago
Apparently the BB attempted to read the less than and greater than signs in your post as html markers.

Please try again, giving your < and > better spacing, and see if it works...

As for what a "for" loop does...

It first assigns your variable to the first thing you give it, so your variable starts at zero. The second parameter tells it how long to increment by checking whether or not the statement is true, so it will increment until the second thing is false. The third parameter generally tells it how much to increment by, for instance, an x++ would increment by one, while x+=10 would increment by ten, every time you go through the for loop. You may also increment by another variable, but be careful not to increment overall by zero or you will probably have an infinite loop on your hands. It will repeat the code after the for statement, either a single line or a bunch of code in {'s, until the second parameter is false.

-fel

[This message has been edited by felisandria (edited December 07, 1999).]

~ The opinions stated by this individual are the opinions of this individual and not the opinions of her company, any organization she might be part of, her parrot, or anyone else. ~
Advertisement
Oh great...
for (render_it_y = 0; render_it_y "<" num_y_tiles; render_it_y++ )
I don't understand these C functions very well. So what does this mean?

for (render_it_y = 0; render_it_y<num_y_tiles; render_it_y++)

I looked at the HTML source, and I can see what you typed in. I'll try to put it in a code block.

code:
for (render_it_y = 0; render_it_y < num_y_tiles; render_it_y++)

That's a for loop in C. It breaks down into 3 parts (separated by ;'s).

The first part is initialization. In this case, render_it_y is set to 0.

The second part is the condition expression. This expression just tests to see if we should continue looping, even on the first iteration. In this case, the loop will continue as long as render_it_y is less than num_y_tiles.

The third part is the loop expression. This expression is evaluated at the end of each iteration. In this example, it increments the value of render_it_y by 1 (that's what ++ does to a variable, that's why it's called C++ BTW...).

The BASIC equivalent (in case you know BASIC) of this would be:

code:
For render_it_y = 0 to num_y_tiles - 1   ' Whatever code goes here...Next render_it_y

[This message has been edited by Kentamanos (edited December 07, 1999).]

-Kentamanos

This topic is closed to new replies.

Advertisement