Page 1 of 1

another noob question

PostPosted: Sat Jul 31, 2010 8:58 am
by drinkingpee
could any of you explain what a "conditional statement" is and how can i use it?, the simpler it is the better :D :D :D

Re: another noob question

PostPosted: Sat Jul 31, 2010 9:49 am
by Bee-Ant
Conditional statement is where you code with conditional code, such as IF, FOR, WHILE, etc...
Here's the example :
Code: Select all
int count;
int number;
if(count<100) //if count value is under 100
{
    number+=1; //add number by 1
}

Code: Select all
int loop;
int number;
for(loop=0;loop<100;loop++) //for loop is equal 0 and under 100, add loop by 1
{
    number+=1; //add number by 1 while adding the loop
}

Code: Select all
int loop;
int number;
while(loop<100) //while loop value is under 100
{
    number+=1; //add number by 1
}

3 of those would store the same value, it's number=100

Re: another noob question

PostPosted: Sun Aug 01, 2010 12:24 pm
by savvy
or
Code: Select all
if(jump==1)
{
yvelocity=-8;
jump=0;
}
else
{
yvelocity=2;
}

that code makes the player jump...or dive!

Re: another noob question

PostPosted: Sun Aug 01, 2010 5:55 pm
by drinkingpee
thanks for the help guys :D :D