While, Else, etc

Game Editor comments and discussion.

While, Else, etc

Postby darokstar » Tue Jul 01, 2008 9:06 pm

You know when you type in things like if, void, while, else, etc the word turns a dark blue colour I wanted to know how a few of those work I already know how if, void and int work... Look its mr green. :D :mrgreen:
I may be an idiot but that doesnt mean im dumb
darokstar
 
Posts: 13
Joined: Sat Jun 07, 2008 5:51 am
Score: 0 Give a positive score

Re: While, Else, etc

Postby Thanx » Tue Jul 01, 2008 9:29 pm

do you know else? If not here's that:
if(smething is something)
{
do something
}
else
{
do something else
}
else is good to escape extra if statements, so you don't want to say
if(something is eomthing
{ ... }
if(something is somehing else}
{

etc...
there are 3 loops in C code
one is for, that also turns dark blue
for(i = 0; i < 120; i ++)
{
do something with i //this is good when you haave similar code that is repeated with only changes in value, oor when you do an array, then this can be useful. after for first define where the looping variable should start from, then how long it should go (here until 120), and then, you tell it how much it should add or take away from the loop variable. Use when ou know how mny times the loop will go around. Note: the varable doesn't have to be i, though i is used a lot.

while is a loop used where you're not sure how many times you'll want the code to execute. It has another keyword you use: do...
so
do
{
the looops code
}
while(something is something)
this loop will execute at least once, like for. There's a loop that might not even happen once:
until(something is something)
{
do loop
}
this might not happen, cause you checked conditions at the beginning not at the end like at while. for doesn't test at all, that's fully specified...

int, as you know is for defining an integer. Now char is used the similar way to make a string variable, and real is used the same way for real numbers, and then there's double, and float, those are also types, but I'm not sure what the differences are there, just use REAL... :D That sounds more realistic...
That's what I could think of blue code now! Ya, I see mr green too!!!! :mrgreen: :mrgreen: :mrgreen:
http://www.youtube.com/watch?v=XyXexDJBv58
http://www.youtube.com/watch?v=Be4__gww1xQ
These are me and playing the piano (second one with a friend/fellow student)
Hope you watch and enjoy!
User avatar
Thanx
 
Posts: 314
Joined: Sat Jan 26, 2008 10:07 pm
Location: Home sweet home! :)
Score: 24 Give a positive score

Re: While, Else, etc

Postby darokstar » Thu Jul 03, 2008 4:13 am

Thanks... MR GREEN VS EXCLAMATION!!! :mrgreen: :!: :mrgreen: :!:
I may be an idiot but that doesnt mean im dumb
darokstar
 
Posts: 13
Joined: Sat Jun 07, 2008 5:51 am
Score: 0 Give a positive score

Re: While, Else, etc

Postby Spidy » Thu Jul 03, 2008 7:33 am

Nice Info Thanx :D
Image
VOTE FOR MY SIGNATURE PLEASE.......THANK YOU
User avatar
Spidy
 
Posts: 935
Joined: Tue Aug 14, 2007 1:28 pm
Location: http://www.inatonibai.com
Score: 38 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron