#10141 - RaBBi - Wed Aug 27, 2003 10:21 pm
hi !
I tried for the first time to clean my code by playing with .h, .c and extern :P
After many bugs, I got a "hopefull" last error message :
I pass a pointer on structure as a param to a function.
When all my code was in main.C, it worked.
But now that I use .h includes, it doesn't.
Here come prototype and function :
And of course, I don't know where this error come from.
So while I'm reading some C books, can someone guide me ? ^^
Thanks in advance ^^
_________________
Sorry for my poor english, but it would be worst for you to understand me if I speak in my native language, French ^^
I tried for the first time to clean my code by playing with .h, .c and extern :P
After many bugs, I got a "hopefull" last error message :
Code: |
sprites.h:6: parse error before '*' token |
I pass a pointer on structure as a param to a function.
When all my code was in main.C, it worked.
But now that I use .h includes, it doesn't.
Here come prototype and function :
Code: |
(in sprites.h) void random_move (TSprite *T_sprite, u16 direction, unsigned char* bitmap, unsigned char* vitesse); (in sprites.c) typedef struct TSprite { u8 ObjNo; s16 X, Y; s8 SpeedX, SpeedY; bool inMotion; u16 direction; u8 compteur_pas; u8 limite_pas; u8 AnimCnt; u32 frames; }TSprite; #define SPRITES_MAX 2 TSprite g_SprObj[SPRITES_MAX]; /********************************************************************************* * random_move(sprite_no, direction, *bitmap, *vitesse) * * D?place un sprite de mani?re al&atoire en process parall?le ********************************************************************************/ void random_move(TSprite *T_sprite, u16 direction, unsigned char* bitmap, unsigned char* vitesse) { u16 sprite_Y = MY_OBJ_GET_Y_VALUE(T_sprite->ObjNo); u16 sprite_X = MY_OBJ_GET_X_VALUE(T_sprite->ObjNo); u16 rand_direction = 0; u16 opp_rand_direction = 0; if (T_sprite->compteur_pas == 0) { do { rand_direction = (int)((double)rand() / ((double)RAND_MAX + 1) * 4); opp_rand_direction = (rand_direction ^ 2); if (opp_rand_direction > 3) opp_rand_direction=0; rand_direction = rand_direction*3*1024; opp_rand_direction = opp_rand_direction*3*1024; } while ((rand_direction == (T_sprite->direction)) || (opp_rand_direction == (T_sprite->direction))); T_sprite->direction = rand_direction; //ham_DrawText(0, 1, "%4d", rand_direction); //ham_DrawText(0, 2, "%4d", opp_rand_direction); //T_sprite->compteur_pas = (int)((double)rand() / ((double)RAND_MAX + 1) * T_sprite->limite_pas); T_sprite->compteur_pas = 50; } if (T_sprite->compteur_pas != 0) { //if(g_NewFrame) //{ // On n'update l'animation que toutes les 5 frames, if(!(T_sprite->frames%(vitesse[0]))) { // charge le nouveau graph du sprite //ham_UpdateObjGfx(sprite_no,(void*)&eikishi_Bitmap[g_DirectionAnim+1024*(g_AnimCnt%3)]); ham_UpdateObjGfx(T_sprite->ObjNo,(void*)&bitmap[T_sprite->direction+1024*(T_sprite->AnimCnt%3)]); // mise ? jour de la position du perso T_sprite->AnimCnt++; } if(!(T_sprite->frames%(vitesse[1]))) { switch(T_sprite->direction) { //haut case ANIM_HAUT: sprite_Y--; break; //bas case ANIM_BAS: sprite_Y++; break; //gauche case ANIM_GAUCHE: sprite_X--; break; //droite case ANIM_DROITE: sprite_X++; break; } redrawHero(T_sprite->ObjNo,sprite_X,sprite_Y); T_sprite->compteur_pas--; //RE-INIT du compteur de pas if (T_sprite->compteur_pas==0) { //T_sprite->compteur_pas=T_sprite->limite_pas; } } // Incr?mente le compteur de frames //g_NewFrame=0; // Mise ? z?ro du bool?en Nouvelle Frame T_sprite->frames++; //} } } |
And of course, I don't know where this error come from.
So while I'm reading some C books, can someone guide me ? ^^
Thanks in advance ^^
_________________
Sorry for my poor english, but it would be worst for you to understand me if I speak in my native language, French ^^