DragonFireSDK Forum

Programming Discussions => Game Programming => Topic started by: gavdra on January 08, 2013, 07:52:56 pm

Title: change a const int?
Post by: gavdra on January 08, 2013, 07:52:56 pm
I need to change a const int for a game im making.

right here i make it 1
Code: [Select]

const int MAX_BALLS = 1;


typedef struct
{
    int ViewHandle;
    float XVelocity;
    float YVelocity;

}
BallInfo;
BallInfo Ball[MAX_BALLS];
int BallWidth;
int BallHeight;
int BallImage;


and then later using ontimer at a certain point i want to change it to 2 so the game will have two balls instead of just one. any idea? THANKS IN ADVANCE!
Title: Re: change a const int?
Post by: nednones on January 09, 2013, 05:45:07 am
You cannot change a const int, hence why it is called a constant variable. Once declared, the compiler will assign the value to it in the permanent stack heap (memory) and is therefore not accessible for write operations during the execution of your software. Hope that helps.

You should only use a global variable if you need to modify during different stages of your program although try and avoid using too many globals as this is not good software programming practice
Title: Re: change a const int?
Post by: DeadSn0wMan on January 09, 2013, 07:07:06 am
just use regular int insted