Explain the for statement again, I could make something good

Non-platform specific questions.

Explain the for statement again, I could make something good

Postby Hblade » Sun Dec 06, 2009 2:06 pm

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++;
}

Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

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

Postby GeoGia » Mon Dec 07, 2009 7:47 am

*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
You don't know what you can do unless you've already done it
GeoGia
 
Posts: 19
Joined: Wed Nov 04, 2009 1:30 am
Score: 2 Give a positive score

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

Postby Hblade » Mon Dec 07, 2009 12:55 pm

Yeah I figured it out like 5 mins after this post by looking at one of my older topics :D
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

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

Postby GeoGia » Mon Dec 07, 2009 2:43 pm

Ah good :)
You don't know what you can do unless you've already done it
GeoGia
 
Posts: 19
Joined: Wed Nov 04, 2009 1:30 am
Score: 2 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron