wow! thanks so much r0shi, it worked. I can not type how appreciative I am! As usual another problem arose...
I have multiple enemy types and they are not all arrays.
for example in main i have something like:
|
boss = (ENEMY*)malloc(sizeof(ENEMY));
|
and then what you told me
1 2
|
ENEMY *zombie;
zombie = new ENEMY[ENEMYCOUNT];
|
so there is a boss, and ENEMYCOUNT = 10 enemies. When I initialize them for the single boss I have:
1 2 3 4 5 6
|
void init_enemy(ENEMY * enemy)
{
enemy->x = 200;
enemy->y = 300;
//etc...
}
|
for the 10 enemies of course I want their positions to be different so I want to overload the init_enemy function to handle this array of 10 guys. This is what I wanted to type:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
void init_enemy(ENEMY * enemy[])
{
for(int n = 0 ; n< ENEMYCOUNT ; n++)
{
enemy[n]->curframe=0;
enemy[n]->framecount=0;
//etc...
}
for(int n = 0 ; n< ENEMYCOUNT ; n++)
{
enemy[n]->x = 200*2 + 20*n;
enemy[n]->y = 300;
}
}
|
something like this but it will not work. It actually builds but the first time it tries to access guard[1] there is no set value which means it used the first function and not the 2nd one overloading it. The guard is getting passed the same as boss, pointer to an object of ENEMY, not an array...
This is how I am calling them:
1 2
|
init_enemy(boss);
init_enemy(guard);
|
Thanks again for the previous response!