diff options
Diffstat (limited to 'sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c')
-rw-r--r-- | sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c | 731 |
1 files changed, 1 insertions, 730 deletions
diff --git a/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c b/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c index 6a2a328..df0e46d 100644 --- a/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c +++ b/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c @@ -329,7 +329,7 @@ int reachedPlateau(int x, int y, int size, int dir) { err=get_pixel32(x,y,pStencil); if(err==ccc_error){return 115;} - if((err==ccc_oNoDigLeft)||(err==ccc_oNoDigRight)){ + if( (err==ccc_oNoDigLeft) || (err==ccc_oNoDigRight) ){ return 0; } @@ -1008,63 +1008,6 @@ int stateLemming(struct gameInit *gInit){ return 0; } - int putBrickPx(int x,int y,SDL_Surface *s,Uint32 bgColor,Uint32 debrisColor){ - int err; - SDL_Rect from,to; - - from.x=0; - from.y=0; - from.w=s->w; - from.h=s->h; - - to.x=x; - to.y=y; - to.w=x+s->w; - to.h=y+s->h; - - if((err=paint_manip(s,from,pTerrain,to,bgColor,ccc_lemming,17,pStencilFixe))!=0){ - return err; - } - if((err=paint_manip(s,from,pStencilFixe,to,ccc_bgStencil,ccc_lemming,18,NULL))!=0){ - return err; - } - - return 0; - } - - int ereasePx(int x,int y,SDL_Surface *s,Uint32 bgColor){ - int err; - SDL_Rect from,to; - - from.x=0; - from.y=0; - from.w=s->w; - from.h=s->h; - - to.x=x; - to.y=y; - to.w=x+s->w; - to.h=y+s->h; - - if((err=paint_manip(s,from,pTerrain,to,bgColor,ccc_lemming,17,pStencil))!=0){ - return err; - } - - if((err=paint_manip(s,from,pSpr_Lem,to,bgColor,ccc_lemming,17,pStencil))!=0){ - return err; - } - - if((err=paint_manip(s,from,pSprLemBack,to,bgColor,ccc_lemming,17,pStencil))!=0){ - return err; - } - - if((err=paint_manip(s,from,pStencil,to,ccc_bgStencil,ccc_lemming,18,NULL))!=0){ - return err; - } - - - return 0; - } int print_num(SDL_Surface *dst, SDL_Surface *src, int x, int y, int value, int nbrMaxOfChiffre) { @@ -1180,92 +1123,6 @@ int stateLemming(struct gameInit *gInit){ } - SDL_Surface* flipSurfaceUD_LR(SDL_Surface* src, enum sens sensO, Uint32 c) { - int i,j; - - SDL_Surface* copy_surface = NULL; - - // This only works for 32 bit pixel format - if( src->format->BitsPerPixel == 32 ) { - // This surface must be freed by the caller. - copy_surface = SDL_CreateRGBSurface(src->flags, src->w, src->h, - src->format->BitsPerPixel, - - src->format->Rmask, - src->format->Gmask, - src->format->Bmask, - src->format->Amask); - - SDL_SetColorKey( copy_surface, - SDL_RLEACCEL | SDL_SRCCOLORKEY, - //src->format->colorkey - SDL_MapRGB( copy_surface->format, - (c >> 16) & 0xff, - (c >> 8) & 0xff, - (c & 0xff)) - ); - - //FIXME : lock surface - Uint32 *source = src->pixels; - Uint32 *dest = copy_surface->pixels; - - for(i = 0; i < src->h; i++) { - for(j = 0; j < src->w; j++) { - if (sensO == UD){// Sens UD - dest[ (src->h-i-1)*src->w + j ] = source[ i*src->w + j]; - } - if (sensO == LR){// Sens LR - dest[ i*src->w + (src->w-j-1) ] = source[ i*src->w + j]; - } - } - } - } - - return copy_surface; - } - - SDL_Surface *load_image( char* filename, Uint32 cbg ) - { - //L'image qui est chargée - SDL_Surface* loadedImage = NULL; - - //L'image optimisée qu'on va utiliser - SDL_Surface* optimizedImage = NULL; - - //Chargement de l'image - loadedImage = IMG_Load( filename ); - - //Si l'image est chargée - if( loadedImage != NULL ) - { - //Création de l'image optimisée - optimizedImage = SDL_DisplayFormat( loadedImage ); - - - - //Si la création de l'image optimisée s'est bien passée - if( optimizedImage != NULL ) - { - SDL_SetColorKey( optimizedImage, - SDL_RLEACCEL | SDL_SRCCOLORKEY, - SDL_MapRGB( optimizedImage->format, - (cbg >> 16) & 0xff, - (cbg >> 8) & 0xff, - (cbg & 0xff) - ) - ); - } - //Libération de l'ancienne image - SDL_FreeSurface( loadedImage ); - } - - //On retourne l'image optimisée - return optimizedImage; - - //return loadedImage; - } - - int load_fields(char *folder, struct gameInit *gInit, int tabNum[255] ) { int i, lt,total,cpt=-1,llem; char *temp; @@ -1508,227 +1365,6 @@ int stateLemming(struct gameInit *gInit){ } - int load_files(struct gameInit *gInit) - { - int lt,ltt,ltlem; - int err=0; - int res, lterrain, lobjet, lsteel; - char *folder; - char *spriteINI; - char *lemINI; - char *terrainGif; - char *objetGif; - char *steelGif; - char *temp; - int tabNum[255]; - int i,tempi,max,j; - struct dirent *lecture; - DIR *rep; - - yyparse(gInit); - - fclose(yyin); - //-DEBUG-printf("CLOSE 1\n"); - - - lt = (strlen("../../../styles/")); - ltlem = (strlen("../../../misc/lemming.ini")); - ltt = (strlen(tabString_eMapStyle[gInit->mapI.map.style])); - - folder = malloc(sizeof(char)*(lt+ltt+1)); - spriteINI = malloc(sizeof(char)*(lt+ltt*2+5));// *2:dossier/fichier, +4: .ini, +1: string - lemINI = malloc(sizeof(char)*ltlem+1); - - - //folder = "/home/jazzblue/Bureau/Projet-Lemmings/trunk/styles/dirt"; - //-DEBUG-printf("test segFault\n"); - sprintf(folder,"../../../styles/%s",tabString_eMapStyle[gInit->mapI.map.style]); - sprintf(spriteINI,"%s/%s.ini",folder,tabString_eMapStyle[gInit->mapI.map.style]); - sprintf(lemINI,"%s","../../../misc/lemming.ini"); - //-DEBUG-printf("test2\n"); - - temp = tabString_eMapStyle[gInit->mapI.map.style]; - lt = strlen(temp); - lterrain = lt+1; - lobjet = lt+2; - lsteel = lt+3; - terrainGif=malloc(sizeof(char)*(lterrain+1)); - objetGif=malloc(sizeof(char)*(lobjet+1)); - steelGif=malloc(sizeof(char)*(lsteel+1)); - sprintf(terrainGif,"%s_",temp); - sprintf(objetGif,"%so_",temp); - sprintf(steelGif,"%som_",temp); - - // Compter les textures de terrain - rep = opendir(folder); - if (rep==NULL) { - //-DEBUG-printf("Erreur opendir('%s')\n", folder); - return(31); - } - - while ((lecture = readdir(rep))) { - if( (res=strncmp(terrainGif, lecture->d_name,lterrain)) == 0 ){ - ++(gInit->mapI.map.tiles); - } else { - if( (res=strncmp(objetGif, lecture->d_name,lobjet)) == 0 ) { - ++(gInit->mapI.map.tilesObjet); - } else { - if ( (res=strncmp(steelGif, lecture->d_name,lsteel)) == 0 ) { - sscanf(lecture->d_name+lsteel, "%i", &(tabNum[gInit->mapI.map.tilesSteel])); - ++(gInit->mapI.map.tilesSteel); - - } else { - //-DEBUG-printf("BUG : type de fichier non reconnu [%s] \n", lecture->d_name); - } - } - } - } - closedir(rep); - - //tri tableau - for(j=0;j<2;++j){ - for(i=0;i<gInit->mapI.map.tilesSteel-1;++i){ - max=tabNum[i]; - tempi=tabNum[i+1]; - - if(max > tempi){ - tabNum[i]=tempi; - tabNum[i+1]=max; - i=0; - } - } - } - - yyin=fopen(spriteINI, "r"); - if (yyin==NULL) { fprintf(stderr,"Filename INVALIDE: %s\n",spriteINI); - perror("Impossible d'ouvrir le fichier de configuration des sprite"); return(32); - } - yyparse(gInit); - fclose(yyin); - //-DEBUG-printf("CLOSE 2\n"); - - yyin=fopen(lemINI, "r"); - if (yyin==NULL) { fprintf(stderr,"Filename INVALIDE: %s\n",lemINI); - perror("Impossible d'ouvrir le fichier de configuration des lemmings"); return(33); - } - yyparse(gInit); - fclose(yyin); - //-DEBUG-printf("CLOSE 3\n"); - - //-DEBUG-printf("REVERSE t.lt\n"); - gInit->t.lt=(struct listeSimplementChainee*)rev_listeO(gInit->t.lt); - //-DEBUG-printf("REVERSE o.lo\n"); - gInit->o.lo=(struct listeSimplementChainee*)rev_listeO(gInit->o.lo); - //-DEBUG-printf("REVERSE s.ls\n"); - gInit->s.ls=(struct listeSimplementChainee*)rev_listeO(gInit->s.ls); - - err=load_fields(folder, gInit, tabNum); - if(err!=0){return err;} - - - // AFFICHAGE DES INFOS DE LA MAP - //err=afficher(gInit); - //if(err!=0){return err;} - - //Si tout s'est bien passé - free(terrainGif); - free(objetGif); - free(steelGif); - free(folder); - free(spriteINI); - free(lemINI); - - return 0; - } - - int afficher(struct gameInit *gInit){ - - int i; - struct listeSimplementChainee *k; - - printf("AFFICHAGE DE GAME INIT\n"); - printf("LES PARAMETRES:\n"); - for(i=0;i<IDENT_COUNT;++i){ - printf("\t%s = %d\n",tabString_eParaMap[i],gInit->mapI.paraMap[i]); - } - printf("\txPos = %d\n",gInit->mapI.xPos); - printf("\tstyle = %s\n",tabString_eMapStyle[gInit->mapI.map.style]); - - printf("LE NOM DU NIVEAU:\n"); - printf("name = %s\n",gInit->mapI.name); - printf("LES COULEURS DU NIVEAU:\n"); - printf("bgColor R = %X G = %X B = %X\n", - ((gInit->mapI.map.cmap.bgColor>>16) & 0xff), - ((gInit->mapI.map.cmap.bgColor>>8) & 0xff), - (gInit->mapI.map.cmap.bgColor & 0xff) ); - printf("debrisColor R = %X G = %X B = %X\n", - ((gInit->mapI.map.cmap.debrisColor>>16) & 0xff), - ((gInit->mapI.map.cmap.debrisColor>>8) & 0xff), - (gInit->mapI.map.cmap.debrisColor & 0xff) ); - printf("debrisColor:\n"); - for(i=0;i<PARTICULE_COUNT;++i){ - printf("\tP%d: R = %X G = %X B = %X\n",i, - ((gInit->mapI.map.cmap.particleColor[i]>>16) & 0xff), - ((gInit->mapI.map.cmap.particleColor[i]>>8) & 0xff), - (gInit->mapI.map.cmap.particleColor[i] & 0xff) ); - - } - - printf("TERRAINS:\n"); - k=gInit->t.lt; - i=0; - while ( k !=NULL ) { - if(k->data.pt != NULL){//{printf("paraTerrain non initialiser\n");return(34);} - printf("\tterrain_%d = %d, %d, %d, %d\n",i,k->ID, k->x, k->y,k->data.pt->modif); - } - ++i; - k=k->next; - } - - printf("OBJETS:\n"); - - k=gInit->o.lo; - i=0; - while ( k !=NULL ) { - if(k->data.po != NULL){ //{printf("paraObjet non initialiser\n");return(35);} - printf("\tobject_%d = %d, %d, %d, %d, %d\n",i,k->ID, k->x, k->y, k->data.po->paintMode,k->data.po->UD); - } - ++i; - k=k->next; - } - - - printf("STEELS:\n"); - k=gInit->s.ls; - i=0; - while ( k !=NULL ) { - if(k->data.ps != NULL){//{printf("paraSteel non initialiser\n");return(36);} - printf("\tsteel_%d = %d, %d, %d, %d, %d\n",i,k->ID=i, k->x, k->y, k->data.ps->w,k->data.ps->h); // FIXME big fuck here with "=" - } - ++i; - k=k->next; - } - - printf("DATA SPRITES OBJET:\n"); - for(i=0;i<gInit->mapI.map.tilesObjet;++i){ - printf("spr_%d:\n\tframes_%d = %d\n\tanim_%d = %d\n\ttype_%d = %d\n\tsound_%d = %d\n",i,i,gInit->mapI.map.tabDataSprO[i].state,i,gInit->mapI.map.tabDataSprO[i].anim,i,gInit->mapI.map.tabDataSprO[i].type,i,gInit->mapI.map.tabDataSprO[i].sound); - } - - printf("DATA JOB LEMMINGS:\n"); - for(i=0;i<LEM_JOB;++i){ - printf("lem_%d:\n\tlemm_%d = %d, %d, %d\n\tpos_%d = %d, %d, %d\n",i,i,gInit->mapI.lemmingDATA[i].state,gInit->mapI.lemmingDATA[i].dir,gInit->mapI.lemmingDATA[i].anim,i,gInit->mapI.lemmingDATA[i].footX,gInit->mapI.lemmingDATA[i].footY,gInit->mapI.lemmingDATA[i].footSize); - - if (gInit->mapI.lemmingDATA[i].mask != NULL){ - printf("\tmask_%d = %d, %d, %d\n",i,gInit->mapI.lemmingDATA[i].mask->stateM,gInit->mapI.lemmingDATA[i].mask->dirM,gInit->mapI.lemmingDATA[i].mask->cooldown); - } - - if (gInit->mapI.lemmingDATA[i].imask != NULL){ - printf("\timask_%d = %d , %d\n",i,gInit->mapI.lemmingDATA[i].imask->stateI,gInit->mapI.lemmingDATA[i].imask->dirI); - } - } - return 0; - } - int clean_up() { //On libère la feuille de sprites @@ -1813,18 +1449,6 @@ int stateLemming(struct gameInit *gInit){ return 0; } - int test_O_UD(int UD){ - - switch(UD){ - case 4 : return 1;break; - case 6 : return 1;break; - case 12 : return 1;break; - case 14 : return 1;break; - default: return 0;break; - } - return 0; - } - int creationLemming(struct gameInit *gInit){ int nbLem; struct listeSimplementChainee *k=NULL; @@ -1952,180 +1576,6 @@ int stateLemming(struct gameInit *gInit){ return 0; } - int paint_terrain (struct gameInit *gInit, int choix){ - struct listeSimplementChainee *k=NULL; - SDL_Rect offset; - SDL_Surface *sf; - int err=0; - int overwrite=0; - int remove=0; - int paint=0; - int tx,ty=0; - int cpt=0; - int ok=0; - Uint32 color; - - // //-DEBUG-printf("LES TERRAINS : "); - k=gInit->t.lt; - while ( k !=NULL ) { - offset.x = k->x; - offset.y = k->y; - - sf = gInit->mapI.map.tabGif[test_O_UD(k->data.pt->modif)+k->ID*2+ADD_OBJ]; - - if((k->data.pt->modif != 0)&& - (k->data.pt->modif != 2)&& - (k->data.pt->modif != 4)&& - (k->data.pt->modif != 6)&& - (k->data.pt->modif != 8)&& - (k->data.pt->modif != 10)&& - (k->data.pt->modif != 12)&& - (k->data.pt->modif != 14)&& - (k->data.pt->modif != 15) - ) { - //-DEBUG-printf("WTF ... k->data.pt->modif == %d\n",k->data.pt->modif); - return(40); - } - for(ty=k->y;ty<sf->h+k->y;++ty){ - - if(ty<0) {ty=-1;continue;} - if(ty>=pTerrain->h){break;} - if(ty>=LEVEL_HEIGHT) {break;} - - for(tx=k->x;tx<sf->w+k->x;++tx){ - - if(tx<0) {tx=-1;continue;} - if(tx>=pTerrain->w){break;} - if(tx>=LEVEL_WIDTH) {break;} - -//FIXME : le bloc suivant ne dépends pas de x et y ! - overwrite = ((k->data.pt->modif & 8) == 8)? 0 : 1; - remove = ((k->data.pt->modif & 2) == 2)? 1 : 0; - if(k->data.pt->modif == 15){ - overwrite=0; - remove=0; - } - - - color = get_pixel32(tx-k->x,ty-k->y,sf); - if(color==ccc_error){return 250;} - if (color == ccc_black) - { //putPixel(pStencil,tx,ty , ccc_tEmpty ); - continue; - } - paint=0; - if(!overwrite){ - //FIXME : What the hell avec deux fois ce get_pixel ?!? - if((get_pixel32(tx,ty,pStencil)==ccc_error)){return 67;} - // don't overwrite -> only paint if background is transparent - if(((get_pixel32(tx,ty,pStencil)>>24) & 0xff ) == 0) - {// ccc_tEmpty){ - paint=1; - } - } else if(remove){ - // if(((get_pixel32(tx,ty,pStencil)) & ccc_tFull) != 0){ - err=putPixel(pTerrain,tx,ty , gInit->mapI.map.cmap.bgColor); - if(err!=0){return err;} - err=putPixel(pStencil,tx,ty , ccc_tRemove );//ccc_tEmpty); - if(err!=0){return err;} - // } - - } else { - paint=1; - } - - if(paint==1){ - if(!overwrite){ - if(!remove){ - err=putPixel(pTerrain,tx,ty ,color); - if(err!=0){return err;} - if(k->data.pt->modif==15){ - err=putPixel(pStencil,tx,ty , ccc_tHidden );//ccc_tBrick); - if(err!=0){return err;} - } else { - err=putPixel(pStencil,tx,ty , ccc_tNoOverwrite );//ccc_tBrick); - if(err!=0){return err;} - } - } else { - err=putPixel(pTerrain,tx,ty ,color); - if(err!=0){return err;} - err=putPixel(pStencil,tx,ty , ccc_tRemoveNoOverwrite );//ccc_tBrick); - if(err!=0){return err;} - } - } else { - err=putPixel(pTerrain,tx,ty ,color); - if(err!=0){return err;} - err=putPixel(pStencil,tx,ty , ccc_tFull );//ccc_tBrick); - if(err!=0){return err;} - } - } - }//fin tx - }//fin ty - k=k->next; - cpt++; - ok=0; - //test_FillRect( screen, &screen->clip_rect, SDL_MapRGB( screen->format, 0x0, 0x0, 0x0 ) ); test_blit(pTerrain, &camera, screen, NULL); if( SDL_Flip( screen ) == -1 ) { return 1;} //scanf("%d",&pas); - } - // elimination des pixel remove - - - for(ty=0;ty<LEVEL_HEIGHT;++ty){ - for(tx=0;tx<LEVEL_WIDTH;++tx){ - color = get_pixel32(tx,ty,pStencil); - if(color==ccc_tRemove){ - err=putPixel(pStencil,tx,ty , ccc_bgStencil ); - if(err!=0){return err;} - } else { - if(color!=ccc_bgStencil){ - err=putPixel(pStencil,tx,ty , ccc_tBrick ); - if(err!=0){return err;} - } - } - } - } - - - // //-DEBUG-printf("LES STEEL : "); - k=gInit->s.ls; - while ( k !=NULL ) { - offset.x = k->x; - offset.y = k->y; - - sf = gInit->mapI.map.tabGif[ADD_OBJ+(gInit->mapI.map.tiles*2)+(gInit->mapI.map.tilesObjet*2)+k->ID]; - - offset.w = k->data.ps->w; - offset.h = k->data.ps->h; - //-DEBUG-printf("H=)> %d\n",offset.h); - - for(ty=k->y;ty<offset.h+k->y;++ty){ - - if(ty<0) {ty=-1;continue;} - if(ty>pTerrain->h){break;} - if(ty>=LEVEL_HEIGHT) {break;} - - for(tx=k->x;tx<offset.w+k->x;++tx){ - - if(tx<0) {tx=-1;continue;} - if(tx>pTerrain->w){break;} - if(tx>=LEVEL_WIDTH) {break;} - - color = get_pixel32(tx,ty,pStencil); - if(color==ccc_error){return 219;} - if (color == ccc_black){ - continue; - } else { - err=putPixel(pStencil,tx,ty , ccc_s ); - if(err!=0){return err;} - } - } - } - // test_FillRect(pStencil, &offset, ccc_s); - k=k->next; - } - //} - - return 0; - } int miniMapLemming (struct gameInit *gInit){ @@ -2316,185 +1766,6 @@ int stateLemming(struct gameInit *gInit){ } - int paint_manip(SDL_Surface *spr,SDL_Rect from,SDL_Surface *t,SDL_Rect to,Uint32 ccc_t, Uint32 ccc_spr, int mode, SDL_Surface *stencil){ - - int size,i,j,err; - void *temp_pixels = NULL; - Uint32 ccc_temp=0x00000000; - Uint32 ccc_temp2=0x00000000; - Uint32 ccc_temp3=0x00000000; - - //FULL - if(mode==0){ - err=test_blit(spr,&from, t,&to,0); - return err; - } - - //-DEBUG-printf("paint_manip(), from.x==%4i, from.y==%4i, from.h==%4i, from.w==%4i, from to.x==%4i, to.y==%4i\n", from.x, from.y, from.h, from.w, to.x, to.y); - - if(from.y<0 || from.y > spr->h) { - //-DEBUG- - printf("paint_manip(1) rectFrom_Y out, from.x==%4i, FROM.Y==%4i, from.h==%4i, from.w==%4i, from to.x==%4i, to.y==%4i\n", from.x, from.y, from.h, from.w, to.x, to.y); - return 0; - } - - if(from.x<0 || from.x > spr->w) { - //-DEBUG- - printf("paint_manip(2) rectFrom_X out, FROM.X==%4i, from.y==%4i, from.h==%4i, from.w==%4i, from to.x==%4i, to.y==%4i\n", from.x, from.y, from.h, from.w, to.x, to.y); - return 0; - } - - if(to.y<0 || to.y > t->h) { - //-DEBUG- - printf("paint_manip(3) rectTO_Y out, from.x==%4i, from.y==%4i, from.h==%4i, from.w==%4i, from to.x==%4i, TO.Y==%4i\n", from.x, from.y, from.h, from.w, to.x, to.y); - return 0; - } - - if(to.x<0 || to.x > t->w) { - //-DEBUG- - printf("paint_manip(4) rectTO_X out, from.x==%4i, from.y==%4i, from.h==%4i, from.w==%4i, from TO.X==%4i, to.y==%4i\n", from.x, from.y, from.h, from.w, to.x, to.y); - return 0; - } - - if(from.y+from.h > spr->h) { - from.h=spr->h - from.y; - } - - if(from.x+from.w > spr->w) { - from.w=spr->w - from.x; - } - - if(to.y+from.h > t->h) { - from.h=t->h - to.y; - } - - if(to.x + from.w > t->w) { - from.w=t->w - to.x; - } - - size=spr->h*spr->pitch; - temp_pixels=malloc(size); - - SDL_LockSurface(spr); - SDL_LockSurface(t); - if(stencil!=NULL) SDL_LockSurface(stencil); - memcpy(temp_pixels,spr->pixels,size); - - // NO OVERWRITE - if(mode==4){ - - for(j=0;j<from.h;j++) { - for(i=0;i<from.w;i++) { - /* if((to.y+j)*t->w+(to.x+i)>=(t->w*t->h)){ - //-DEBUG-printf("out of bound1 x=%d + i=%d, y=%d + j=%d * t->w %d == %d >= %d (t->h %d, from.h %d) \n",to.x,i,to.y,j,t->w,(to.y+j)*t->w+(to.x+i),(t->w*t->h),t->h,from.h); - return 56; - //continue; - }*/ - ccc_temp=((Uint32 *)t->pixels)[(to.y+j)*t->w+(to.x+i)]; - //-DEBUG-printf("ccc_temp1 = %p == %p t->format->colorkey\n",ccc_temp,t->format->colorkey); - if (ccc_temp!=ccc_t) { - ((Uint32 *)spr->pixels)[(from.y+j)*spr->w+from.x+i]=ccc_temp;//spr->format->colorkey; - } - } - } - } - // VIS ON TERRAIN - if(mode==8){ - for(j=0;j<from.h;j++) { - for(i=0;i<from.w;i++) { - /* if((to.y+j)*t->w+(to.x+i)>=(t->w*t->h)){ - //-DEBUG-printf("out of bound2 x=%d + i=%d, y=%d + j=%d * t->w %d == %d >= %d (t->h %d, from.h %d) \n",to.x,i,to.y,j,t->w,(to.y+j)*t->w+(to.x+i),(t->w*t->h),t->h,from.h); - return 57; - //continue; - }*/ - ccc_temp=((Uint32 *)t->pixels)[(to.y+j)*t->w+(to.x+i)]; - //-DEBUG-printf("ccc_temp1 = %p == %p ccc_t\n",ccc_temp,ccc_t); - if (ccc_temp==ccc_t) { - ((Uint32 *)spr->pixels)[(from.y+j)*spr->w+from.x+i]=ccc_t;//spr->format->colorkey; - - } - } - } - } - // erease pixel - if(mode==17){ - for(j=0;j<from.h;j++) { - for(i=0;i<from.w;i++) { - /* if((to.y+j)*t->w+(to.x+i)>=(t->w*t->h)){ - //-DEBUG-printf("out of bound2 x=%d + i=%d, y=%d + j=%d * t->w %d == %d >= %d (t->h %d, from.h %d) \n",to.x,i,to.y,j,t->w,(to.y+j)*t->w+(to.x+i),(t->w*t->h),t->h,from.h); - return 57; - //continue; - }*/ - ccc_temp=((Uint32 *)spr->pixels)[(from.y+j)*spr->w+from.x+i];//((Uint32 *)t->pixels)[(to.y+j)*t->w+(to.x+i)]; - ccc_temp2=((Uint32 *)t->pixels)[(to.y+j)*t->w+(to.x+i)]; - ccc_temp3=((Uint32 *)stencil->pixels)[(to.y+j)*stencil->w+(to.x+i)]; - //-DEBUG-printf("ccc_temp1 = %p == %p ccc_t\n",ccc_temp,ccc_t); - if ((ccc_temp!=ccc_spr)&&((ccc_tBrick==ccc_temp3)||((ccc_temp3 & 0xff)==0xcb))) { - ((Uint32 *)spr->pixels)[(from.y+j)*spr->w+from.x+i]=ccc_t;//spr->format->colorkey; - } else { - ((Uint32 *)spr->pixels)[(from.y+j)*spr->w+from.x+i]=ccc_temp2; - } - } - } - } - // erease pixel - if(mode==18){ - for(j=0;j<from.h;j++) { - for(i=0;i<from.w;i++) { - /* if((to.y+j)*t->w+(to.x+i)>=(t->w*t->h)){ - //-DEBUG-printf("out of bound2 x=%d + i=%d, y=%d + j=%d * t->w %d == %d >= %d (t->h %d, from.h %d) \n",to.x,i,to.y,j,t->w,(to.y+j)*t->w+(to.x+i),(t->w*t->h),t->h,from.h); - return 57; - //continue; - }*/ - ccc_temp=((Uint32 *)spr->pixels)[(from.y+j)*spr->w+from.x+i];//((Uint32 *)t->pixels)[(to.y+j)*t->w+(to.x+i)]; - ccc_temp2=((Uint32 *)t->pixels)[(to.y+j)*t->w+(to.x+i)]; - //-DEBUG- - // printf("ccc_temp = %p != %p ccc_spr && ccc_tBrick %p == %p ccc_temp2\n",ccc_temp,ccc_spr,ccc_tBrick,ccc_temp2); - if ((ccc_temp!=ccc_spr)&&((ccc_tBrick==ccc_temp2)||((ccc_temp2 & 0xff)==0xcb))) { - ((Uint32 *)spr->pixels)[(from.y+j)*spr->w+from.x+i]=ccc_t;//spr->format->colorkey; - } else { - ((Uint32 *)spr->pixels)[(from.y+j)*spr->w+from.x+i]=ccc_temp2; - } - } - } - } - // objet trap - if(mode==19){ - for(j=0;j<from.h;j++) { - for(i=0;i<from.w;i++) { - /* if((to.y+j)*t->w+(to.x+i)>=(t->w*t->h)){ - //-DEBUG-printf("out of bound2 x=%d + i=%d, y=%d + j=%d * t->w %d == %d >= %d (t->h %d, from.h %d) \n",to.x,i,to.y,j,t->w,(to.y+j)*t->w+(to.x+i),(t->w*t->h),t->h,from.h); - return 57; - //continue; - }*/ - ccc_temp=((Uint32 *)spr->pixels)[(from.y+j)*spr->w+from.x+i];//((Uint32 *)t->pixels)[(to.y+j)*t->w+(to.x+i)]; - ccc_temp2=((Uint32 *)t->pixels)[(to.y+j)*t->w+(to.x+i)]; - //-DEBUG-printf("ccc_temp1 = %p == %p ccc_t\n",ccc_temp,ccc_t); - if (ccc_temp!=ccc_spr){ - ((Uint32 *)spr->pixels)[(from.y+j)*spr->w+from.x+i]=ccc_t;//spr->format->colorkey; - } else { - ((Uint32 *)spr->pixels)[(from.y+j)*spr->w+from.x+i]=ccc_temp2; - } - } - } - } - - - if(stencil!=NULL) SDL_UnlockSurface(stencil); - SDL_UnlockSurface(t); - SDL_UnlockSurface(spr); - test_blit(spr,&from, t,&to,0); - - SDL_LockSurface(spr); - memcpy(spr->pixels,temp_pixels,size); - SDL_UnlockSurface(spr); - - free(temp_pixels); - - return 0; - - } - int paint_objet (struct gameInit *gInit, int cptFps){ SDL_Rect offset,objetAnim,rStencil; SDL_Surface *sf; |