by Kalladdolf » Sun Apr 19, 2009 11:54 am
You can write: int juan;
That creates the variable "juan" which can contain many different values. Right now it contains zero.
int juan = 1; This gives juan the value "1" as soon as the number's created.
int juan = 56; Now juan is 56.
juan = 23; This can be used anywhere in your code now, IF you have created juan at the beginning of the code.
if(juan == 1) If the variable juan is one...
if(juan == 4) {juan = 1;} If juan is 4, change it back to 1.
juan = juan +1; Add 1 to juan.
juan += 1; Means exactly the same.
Now I could continue the list, but I think you get the picture.
You can also use != or < or > or >= or <= in your "if" conditions.
If you int juan in a global code, the variable will be global.
If you int it in another script (such as DrawActor, CreateActor, Collision, MoveFinish), it will be an actor variable.
Global variables can be used for omnipresent things such as Menu, Pause, Music.
Actor variables are better for health, money, score and other individual things.