Page 1 of 1

Explain the for statement again, I could make something good

PostPosted: Sun Dec 06, 2009 2:06 pm
by Hblade
Hey, I've figured out how to make the Perfect HP bar, and it reads pixel by pixel :D But I need to know how to use the for statement so that I can make the HP bar fill up instatnly instead of slowly filling up :D
I need this transformed into a for statement
Code: Select all
if (i<hp)
{
    setpen(0, 255, 255, 0, 3);
    moveto(i, 0);
    lineto(i, height-1);
    i++;
}


Re: Explain the for statement again, I could make something good

PostPosted: Mon Dec 07, 2009 7:47 am
by GeoGia
*looks around for other forum users*

I know I'm not the only one who knows how to use a for loop.. :p

For has three arguments. First is initial value, second is exit condition, third is what to do to the variable each iteration. So for example

for(i=0;i<10;i++){
Do stuff here;}

i starts at zero, gets +1 every iteration, and the loop ends when i is no longer less than 10, hope that helps

Re: Explain the for statement again, I could make something good

PostPosted: Mon Dec 07, 2009 12:55 pm
by Hblade
Yeah I figured it out like 5 mins after this post by looking at one of my older topics :D

Re: Explain the for statement again, I could make something good

PostPosted: Mon Dec 07, 2009 2:43 pm
by GeoGia
Ah good :)