I Need help understanding variables

Game Editor comments and discussion.

I Need help understanding variables

Postby skyler » Wed Mar 26, 2008 1:41 am

I need help understanding variables

i cant really find a tutorial to understand, umm post things here to help me out :D
Image
Wudup Braaaa
User avatar
skyler
 
Posts: 11
Joined: Wed Mar 05, 2008 3:05 am
Location: somewhere, smokin a joint
Score: 0 Give a positive score

Re: I Need help understanding variables

Postby stevenp » Wed Mar 26, 2008 3:41 am

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 :)
User avatar
stevenp
 
Posts: 403
Joined: Sat Dec 22, 2007 12:49 pm
Location: canada, ontario
Score: 16 Give a positive score

Re: I Need help understanding variables

Postby edh » Wed Mar 26, 2008 1:07 pm

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.
User avatar
edh
 
Posts: 233
Joined: Thu Sep 13, 2007 12:17 am
Location: Maine, USA
Score: 14 Give a positive score

Re: I Need help understanding variables

Postby thunderios » Thu Mar 27, 2008 5:52 pm

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.
thunderios
 
Posts: 87
Joined: Thu Jan 31, 2008 1:18 pm
Score: 1 Give a positive score

Re: I Need help understanding variables

Postby edh » Fri Mar 28, 2008 3:37 pm

Good point thunderios! :)
User avatar
edh
 
Posts: 233
Joined: Thu Sep 13, 2007 12:17 am
Location: Maine, USA
Score: 14 Give a positive score

Re: I Need help understanding variables

Postby Freddy » Fri Mar 28, 2008 5:27 pm

Oh no, not algebra!
Hola
User avatar
Freddy
 
Posts: 548
Joined: Sat Jun 02, 2007 3:42 pm
Location: Why do you want to know?
Score: 14 Give a positive score

Re: I Need help understanding variables

Postby Troodon » Fri Mar 28, 2008 6:46 pm

Algebra is intersting but not as interesting as physics...but nothing beats music. :D
I can't die, I already tried
~on the forums since GE 1.3.3~
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score

Re: I Need help understanding variables

Postby Fuzzy » Sat Mar 29, 2008 1:11 am

tekdino wrote:Algebra is intersting but not as interesting as physics...but nothing beats music. :D


Ah, but Music IS physics!
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Re: I Need help understanding variables

Postby Troodon » Sat Mar 29, 2008 6:08 am

And physics is math. And math is "pure science".
So music = pure science.
:?

:D
I can't die, I already tried
~on the forums since GE 1.3.3~
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron