I'm making a small game for a microboard. It's an Arkanoid game. I'm trying to implement a callback in this way:
typedef void (*TPFN_BEHAVIOUR)(int block_number);
typedef struct
{
int square_number;
int initial_x;
int initial_y;
int final_x;
int final_y;
TPFN_BEHAVIOUR behaviour;
}Square;
Square block[150];
Then I do:
block[i].behaviour = app_DetectCollision_SendLife;
where app_Detect_Collision_SendLife is
void app_DetectCollision_SendLife(int i){
int initial_x = block[i].final_x - block[i].initial_x - 5;
int initial_y = block[i].final_y;
services_Screen_Draw(heart, initial_x, initial_y, 10, 9);
}
I'm getting the error shown in the title in the following line:
block[special_block].behaviour = app_DetectCollision_SendLife;
One possibility is that the scope where block[special_block].behaviour = app_DetectCollision_SendLife; occurs has an incorrect declaration of block that is not an array. Check that it isn't something like Square block;
THANKS TO
Mark Plotnick
Compiles on my system. Must be blocks
is not known when you use it. If it's located in a different file, use extern to have the compiler know it.
In C file where blocks is defined:
Square block[150];
In C file where blocks is used (or in header file):
extern Square block[150];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.