Bon alors la il y a quelque chose que je ne comprends pas du tout.
J'ai stocké les sprites dans un fichier externe. Le prog principal utilise
ces sprites sans problèmes.
Mais voila, je veux créer une matrice qui stock l'ordre des sprites
ex {{spr1 LIGHT,spr1 DARK},{spr2 LIGHT,spr2 DARK}...} << dans le programme c'est Usprites.
#include <tigcclib.h>
#include <extgraph.h>
#define ymax 13
#define xmax 13
short map[ymax+1][xmax+1]={
{04,-1,04,-1,04,-1,04,-1,04,-1,04,-1,04,-1},
{-2,-3,-2,-3,-2,-3,-2,-3,-2,-3,-2,-3,-2,-3},
{04,-1,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,04,-1},
{-2,-3,-5,03,-1,-5,07,-1,-5,05,-1,-5,-2,-3},
{04,-1,-5,-2,-3,-5,-2,-3,-5,-2,-3,-5,04,-1},
{-2,-3,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-2,-3},
{04,-1,-5,02,-1,-5,01,-1,-5,00,-1,-5,04,-1},
{-2,-3,-5,-2,-3,-5,-2,-3,-5,-2,-3,-5,-2,-3},
{04,-1,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,04,-1},
{-2,-3,-5,-5,06,-1,-5,-5,-5,-5,-5,-5,-5,-5},
{04,-1,-5,-5,-2,-3,-5,-5,-5,-5,-5,-5,-5,-5},
{-2,-3,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-2,-3},
{04,-1,04,-1,04,-1,04,-1,04,-1,04,-1,04,-1},
{-2,-3,-2,-3,-2,-3,-2,-3,-2,-3,-2,-3,-2,-3}};
// prépare les noms des sprites
unsigned long * altarL ;
unsigned long * altarD ;
unsigned long * cryptL ;
unsigned long * cryptD ;
unsigned long * graveyardL ;
unsigned long * graveyardD ;
unsigned long * hauntedL ;
unsigned long * hauntedD ;
unsigned long * zigguratL ;
unsigned long * zigguratD ;
unsigned long * zigguratTL ;
unsigned long * zigguratTD ;
unsigned long * templeL ;
unsigned long * templeD ;
unsigned long * necropolisL ;
unsigned long * necropolisD ;
long *Usprites[8][2]={{}};
void DRAWMAP(short x, short y,short mode);
void move(short x,short y);
short mod16(short x);
void initiate(void);
void empty(void);
void _main()
{
INT_HANDLER ai1,ai5;
ai1=GetIntVec(AUTO_INT_1);
ai5=GetIntVec(AUTO_INT_5);
SetIntVec(AUTO_INT_1,DUMMY_HANDLER);
SetIntVec(AUTO_INT_5,DUMMY_HANDLER);
short mapX=0,mapY=0;
ClrScr();
Usprites[8][2]={
{altarL,altarD},
{cryptL,cryptD},
{graveyardL,graveyardD},
{hauntedL,hauntedD},
{zigguratL,zigguratD},
{zigurratTL,zigguratTD},
{templeL,templeD},
{necropolisL,necropolisD}};
if (!GrayOn())
return;
ClrScr();
Sprite32 (0, 0, 32, altarL, GetPlane(0), SPRT_OR);
Sprite32 (0, 0, 32, altarD, GetPlane(1), SPRT_OR);
Sprite32 (0, 32, 32, cryptL, GetPlane(0), SPRT_OR);
Sprite32 (0, 32, 32, cryptD, GetPlane(1), SPRT_OR);
Sprite32 (0, 64, 32, graveyardL, GetPlane(0), SPRT_OR);
Sprite32 (0, 64, 32, graveyardD, GetPlane(1), SPRT_OR);
Sprite32 (32, 0, 32, hauntedL, GetPlane(0), SPRT_OR);
Sprite32 (32, 0, 32, hauntedD, GetPlane(1), SPRT_OR);
Sprite32 (32, 32, 32, zigguratL, GetPlane(0), SPRT_OR);
Sprite32 (32, 32, 32, zigguratD, GetPlane(1), SPRT_OR);
Sprite32 (32, 64, 32, zigguratTL, GetPlane(0), SPRT_OR);
Sprite32 (32, 64, 32, zigguratTD, GetPlane(1), SPRT_OR);
Sprite32 (64, 0, 32, templeL, GetPlane(0), SPRT_OR);
Sprite32 (64, 0, 32, templeD, GetPlane(1), SPRT_OR);
Sprite32 (64, 32, 32, necropolisL, GetPlane(0), SPRT_OR);
Sprite32 (64, 32, 32, necropolisD, GetPlane(1), SPRT_OR);
ngetchx();
ClrScr();
move(mapX,mapY);
GrayOff();
SetIntVec(AUTO_INT_1,ai1);
SetIntVec(AUTO_INT_5,ai5);
}
void initiate(void)
{
FILE *f = fopen("wardata", "rb");
// prépare la taille des sprites
altarL = malloc(sizeof(unsigned long) * 32);
altarD = malloc(sizeof(unsigned long) * 32);
cryptL = malloc(sizeof(unsigned long) * 32);
cryptD = malloc(sizeof(unsigned long) * 32);
graveyardL = malloc(sizeof(unsigned long) * 32);
graveyardD = malloc(sizeof(unsigned long) * 32);
hauntedL = malloc(sizeof(unsigned long) * 32);
hauntedD = malloc(sizeof(unsigned long) * 32);
zigguratL = malloc(sizeof(unsigned long) * 32);
zigguratD = malloc(sizeof(unsigned long) * 32);
zigguratTL = malloc(sizeof(unsigned long) * 32);
zigguratTD = malloc(sizeof(unsigned long) * 32);
templeL = malloc(sizeof(unsigned long) * 32);
templeD = malloc(sizeof(unsigned long) * 32);
necropolisL = malloc(sizeof(unsigned long) * 32);
necropolisD = malloc(sizeof(unsigned long) * 32);
// recherche les données correspondantes aux sprites
fread (altarL, sizeof(unsigned long), 32, f);
fread (altarD, sizeof(unsigned long), 32, f);
fread (cryptL, sizeof(unsigned long), 32, f) ;
fread (cryptD, sizeof(unsigned long), 32, f) ;
fread (graveyardL, sizeof(unsigned long), 32, f) ;
fread (graveyardD, sizeof(unsigned long), 32, f) ;
fread (hauntedL, sizeof(unsigned long), 32, f) ;
fread (hauntedD, sizeof(unsigned long), 32, f) ;
fread (zigguratL, sizeof(unsigned long), 32, f) ;
fread (zigguratD, sizeof(unsigned long), 32, f) ;
fread (zigguratTL, sizeof(unsigned long), 32, f) ;
fread (zigguratTD, sizeof(unsigned long), 32, f) ;
fread (templeL, sizeof(unsigned long), 32, f) ;
fread (templeD, sizeof(unsigned long), 32, f) ;
fread (necropolisL, sizeof(unsigned long), 32, f) ;
fread (necropolisD, sizeof(unsigned long), 32, f) ;
}
void empty(void){
// libère l'espace utilisé par les sprites
free(altarL) ;
free(altarD) ;
free(cryptL) ;
free(cryptD) ;
free(graveyardL) ;
free(graveyardD) ;
free(hauntedL) ;
free(hauntedD) ;
free(zigguratL) ;
free(zigguratD) ;
free(zigguratTL) ;
free(zigguratTD) ;
free(templeL) ;
free(templeD) ;
free(necropolisL) ;
free(necropolisD) ;
}
void move(short x,short y)
{
short tmpx=1,tmpy=1;
DRAWMAP(x,y,0);
do {
if (tmpx!=x || tmpy!=y)
DRAWMAP(x,y,1);
tmpx=x;
tmpy=y;
if (_keytest(RR_LEFT) && x>-144){
ScrollRight160(GetPlane(0),100);
ScrollRight160(GetPlane(1),100);
x--;
}
if (_keytest(RR_RIGHT) && x<xmax*16 ){
ScrollLeft160(GetPlane(0),100);
ScrollLeft160(GetPlane(1),100);
x++;
}
if (_keytest(RR_UP) && y>-80){
ScrollDown160(GetPlane(0),100);
ScrollDown160(GetPlane(1),100);
y--;
}
if (_keytest(RR_DOWN) && y<ymax*16 ){
// GraySprite16_XOR(posX,posY,16,frame,frame,GetPlane(0),GetPlane(1));
ScrollUp160(GetPlane(0),100);
ScrollUp160(GetPlane(1),100);
y++;
}
} while (!_keytest(RR_ESC));
}
short mod16(short x)
{
return (x-(x%16))/16;
}
// dessine toute la partie d'ecran utilisee
void DRAWMAP(short x, short y,short mode)
{
short i=0,j=0,tmp;
// GraySprite16_XOR_R(posX,posY,16,frame,frame,GetPlane(0),GetPlane(1));
if (mode==0){
for( i = mod16(x); i < (mod16(x)+11); i++)
for( j = mod16(y); j < (mod16(y)+7); j++)
if (i>=0 && i<=xmax && j>=0 && j<=ymax)
GrayClipSprite32_OR_R((16*i)-x,(16*j)-y, 16, Usprites[(map[j][i])][0], Usprites[(map[j][i])][1],GetPlane(0),GetPlane(1));
}
else{
// Initilisation de j
j=mod16(y);
// Cote haut
for( i = mod16(x); i < (mod16(x)+11); i++)
if (i>=0 && i<=xmax && j>=0)
GrayClipSprite32_OR_R((16*i)-x,(16*j)-y, 16, Usprites[(map[j][i])][0], Usprites[(map[j][i])][1],GetPlane(0),GetPlane(1));
// Cote bas
for(tmp=j+5;tmp<j+7;tmp++)
for( i = mod16(x); i < (mod16(x)+11); i++)
if (i>=0 && i<=xmax && tmp<=ymax)
GrayClipSprite32_OR_R((16*i)-x,(16*tmp)-y, 16, Usprites[(map[tmp][i])][0], Usprites[(map[tmp][i])][1],GetPlane(0),GetPlane(1));
// Initialisation de i
i=mod16(x);
// Cote gauche
for( j = mod16(y); j < (mod16(y)+7); j++)
if (i>=0 && j>=0 && j<=ymax)
GrayClipSprite32_OR_R((16*i)-x,(16*j)-y, 16, Usprites[(map[j][i])][0], Usprites[(map[j][i])][1],GetPlane(0),GetPlane(1));
// Cote droit
for(tmp=i+9;tmp<i+11;tmp++)
for( j = mod16(y); j < (mod16(y)+7); j++)
if (tmp<=xmax && j>=0 && j<=ymax)
GrayClipSprite32_OR_R((16*tmp)-x,(16*j)-y, 16, Usprites[(map[j][tmp])][0], Usprites[(map[j][tmp])][1],GetPlane(0),GetPlane(1));
}
}
Mais le problème c'est que le compilateur me donne une "Parse Error Before "{" token" au niveau de Usprites[8][2]={{altarL,altarD},...}
dans le main.
Je vois vraiment pas d'ou vient l'erreur.
Vive! la Ti-89!
(Mon anneau pylorique est complètement fermé. C'est le résultat de la proximité de cet individu.)