Page 1 of 1

a fundamental question about global code

PostPosted: Sun May 29, 2011 4:50 pm
by sonicfire
so, when i do something simple like
Code: Select all
int field[8][8]


in the global code area and give it a name like "startup", is THIS 2d int array then really global
and accessable by every actor in my game ??

Re: a fundamental question about global code

PostPosted: Sun May 29, 2011 5:19 pm
by jimmynewguy
yes, but don't forget to end the line with a semi colon and save the global code

Re: a fundamental question about global code

PostPosted: Sun May 29, 2011 9:48 pm
by lcl
But note that it will be global only if it's not in any function code.
Declarations must be the first things in Global Code.

Like this:
Code: Select all
int myVar[10][10]; //This will be global

void move(int amount)
{
    x += amount;
}


Not this:
Code: Select all
void move(int amount)
{
    int myVar[10][10]; //This will not be global, it will be the functions own variable
    x += amount;
}


:)

Re: a fundamental question about global code

PostPosted: Mon May 30, 2011 3:18 pm
by sonicfire
thanks!