Page 1 of 1

I Need help understanding variables

PostPosted: Wed Mar 26, 2008 1:41 am
by skyler
I need help understanding variables

i cant really find a tutorial to understand, umm post things here to help me out :D

Re: I Need help understanding variables

PostPosted: Wed Mar 26, 2008 3:41 am
by stevenp
a variable is basically a container, and a label

you can create a "container" and "label" it

createing a variable called "kill" will do nothing by itself, so you need to apply it to something

exmple

in KEY DOWN NO REPEAT!! --> script editor
kill=0;

then you can give that "container" a "label" to anythng to do something

if (kill==0)
{
// pick a sound to play... this is the label
}

so every time you you press the button you selected, kill =0 which will play a sound
if you want to get more complex, you can create a toggle by doing this

in KEY DOWN DO NOT REPEAT!!--> script editor
kill=0;

if (kill==0)
{
kill=1;
// do something
}

else
{
kill=0;
//do something
}

this means every 2 times you press the buton, the sound will only be heard once, hence the "toggle"

this is what a variable means to me, others might describe it differently, but the mechanics are the same

hope this helped :)

Re: I Need help understanding variables

PostPosted: Wed Mar 26, 2008 1:07 pm
by edh
After you digest Mojos explanation above, you can take a look at some really detailed stuff about variables here C Variables, Operators, & Preprocessor Directives

Game editor uses C as the syntax, or programming language. So almost anything you can read about C will apply to GE.

Re: I Need help understanding variables

PostPosted: Thu Mar 27, 2008 5:52 pm
by thunderios
I do not know whether you ever had Math on school, but if you had:
have you ever had a formula y=2x.
There you have two variables y and x, which mean the vertical and horizontal axis, if you get one x, the formula tells you that you have two y, etc
It works the same for Kill and any other variables you can imagine.

Re: I Need help understanding variables

PostPosted: Fri Mar 28, 2008 3:37 pm
by edh
Good point thunderios! :)

Re: I Need help understanding variables

PostPosted: Fri Mar 28, 2008 5:27 pm
by Freddy
Oh no, not algebra!

Re: I Need help understanding variables

PostPosted: Fri Mar 28, 2008 6:46 pm
by Troodon
Algebra is intersting but not as interesting as physics...but nothing beats music. :D

Re: I Need help understanding variables

PostPosted: Sat Mar 29, 2008 1:11 am
by Fuzzy
tekdino wrote:Algebra is intersting but not as interesting as physics...but nothing beats music. :D


Ah, but Music IS physics!

Re: I Need help understanding variables

PostPosted: Sat Mar 29, 2008 6:08 am
by Troodon
And physics is math. And math is "pure science".
So music = pure science.
:?

:D