#include #include #include #include #include "main.h" #include "evenements.h" #include "options.h" void chargeniv(FILE *fich) { int x, y, i, n; //int nevt=0; //Coord evt[50]; char niv, c; //printf("Chargement du niveau..."); fscanf(fich, "REGEN=%i\n", ®EN); fscanf(fich, "BONUSFREQ=%i\n", &BONUSFREQ); fscanf(fich, "NBOMBES=%i\n", &NBOMBES); fscanf(fich, "REBOURS=%i\n", &REBOURS); n=aleat(8); if (!danslemenu) for (i=0; i<8; i++) { fscanf(fich, "perso[%*i]:(%i,%i)\n", &x, &y); perso[(i+n)%8].pos.x=x; perso[(i+n)%8].pos.y=y; } else for (i=0; i<8; i++) { fscanf(fich, "perso[%*i]:(%i,%i)\n", &x, &y); perso[i].pos.x=x; perso[i].pos.y=y; } do fread(&niv, 1, 1, fich); while (niv!='{'); fread(&c, 1, 1, fich); for(y=0; y<15; y++) for(x=0; x<16; x++) { int params[260]; int nparams=0; niv=c; while (niv=='\n' || niv==' ') fread(&niv, 1, 1, fich); fread(&c, 1, 1, fich); while (c=='[') { fscanf(fich, "%i]", ¶ms[nparams]); nparams++; fread(&c, 1, 1, fich); } pl[x][y].elem=sol; pl[x][y].type=LIBRE; pl[x][y].anim=0; pl[x][y].frame=0; pl[x][y].bombe=0; pl[x][y].sol=0; pl[x][y].elemsg=NULL; if (nparams) pl[x][y].params=(int *)realloc(pl[x][y].params, nparams*sizeof(int)); for (i=0; i0.9*RAND_MAX) pl[x][y].anim = 1; pl[x][y].frame = aleat(sol->anims[pl[x][y].anim]->nframes); } else { pl[x][y].anim=2; pl[x][y].frame=params[0]; } break; case '#' : pl[x][y].elem=bloc; pl[x][y].type=DESTRUCTIBLE; pl[x][y].sol=1; pl[x][y].frame=(!nparams) ? aleat( bloc->anims[0]->nframes ) : params[0]; break; case '+' : pl[x][y].elem=mur; pl[x][y].type=INDESTRUCTIBLE; pl[x][y].frame=(!nparams) ? aleat ( mur->anims[0]->nframes ) : params[0]; break; case '§' : pl[x][y].elem=mur; pl[x][y].frame=(!nparams) ? aleat ( mur->anims[0]->nframes ) : params[0]; break; case '=' : pl[x][y].elem=tunnel; pl[x][y].type=TUNNEL; pl[x][y].frame=params[0]; break; case '>' : pl[x][y].type=SENSUNIQUE; pl[x][y].elem=fleche; pl[x][y].anim=params[0]; pl[x][y].sol=1; if (danslemenu==2) /* Menu de choix du perso */ animsplus(fleche, params[0], 10, 0, x, y); break; case 'T' : pl[x][y].type=EVENEMENT; pl[x][y].evt=teleportation; animsplus(teleport, 0, 5, 0, x, y); break; case 'O' : pl[x][y].elem=bouton; pl[x][y].sol=1; pl[x][y].type=EVENEMENT; pl[x][y].evt=changecase; break; case '0' : pl[x][y].type=EVENEMENT; pl[x][y].evt=changecase; break; case 'M' : pl[x][y].elem=sol; pl[x][y].type=EVENEMENT; pl[x][y].evt=menuevt; if (danslemenu==2 || (99