summaryrefslogtreecommitdiff
path: root/sdl-test
diff options
context:
space:
mode:
authorDamien Appert <dappert>2010-11-07 18:41:26 +0000
committerDamien Appert <dappert>2010-11-07 18:41:26 +0000
commit2181e6c1b7c9bab930a545b2d00b802a5552c91b (patch)
treed95cf9c79ccb468a6608be1ab081e9e7d8495976 /sdl-test
parent06742f5f2cc4eed2f3ad3ae44c2544fbf8215e8e (diff)
download2010-netlemmings-2181e6c1b7c9bab930a545b2d00b802a5552c91b.tar.gz
2010-netlemmings-2181e6c1b7c9bab930a545b2d00b802a5552c91b.tar.bz2
2010-netlemmings-2181e6c1b7c9bab930a545b2d00b802a5552c91b.zip
boost FPS
git-svn-id: file:///var/svn/2010-netlemmings/trunk@143 077b3477-7977-48bd-8428-443f22f7bfda
Diffstat (limited to 'sdl-test')
-rw-r--r--sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_integrees.c6
-rw-r--r--sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c291
-rwxr-xr-xsdl-test/SDL_tuto/TestParserLemmingsLVL/genereTerrain.sh8
-rw-r--r--sdl-test/SDL_tuto/TestParserLemmingsLVL/parse_ini.yy18
4 files changed, 227 insertions, 96 deletions
diff --git a/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_integrees.c b/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_integrees.c
index d8bd6e0..0dcae5d 100644
--- a/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_integrees.c
+++ b/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_integrees.c
@@ -42,6 +42,12 @@ int init()
if( pStencil == NULL ) {
return 3;
}
+
+ pInterface = SDL_CreateRGBSurface(SDL_HWSURFACE, SCREEN_WIDTH, INTERFACE_HEIGHT,
+ SCREEN_BPP,0,0,0,0);
+ if( pStencil == NULL ) {
+ return 3;
+ }
//Mise en place de la barre caption
SDL_WM_SetCaption( "Test_LVL", NULL );
//No pointer of mouse
diff --git a/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c b/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c
index 309e97b..2d94853 100644
--- a/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c
+++ b/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c
@@ -99,10 +99,13 @@ int anim_objet(int typeS, int typeO, int cptFps, int frames, int *cpt, struct g
return f;
}
-inline Uint32 get_pixel32( int x, int y, SDL_Surface *surface )
+inline Uint32 get_pixel32( int x, int y, SDL_Surface *s )
{
//Convertie les pixels en 32 bit
- Uint32 *pixels = (Uint32 *)surface->pixels;
+ SDL_LockSurface(s);
+ Uint32 *pixels = (Uint32 *)s->pixels;
+ Uint32 ccc = pixels[ ( y * s->w ) + x ];
+ SDL_UnlockSurface(s);
//-DEBUG-printf("4) x=%d,y=%d,p =%X\n",x,y,pixels[ ( y * surface->w ) + x ]);
//Recupere le pixel demande
@@ -121,8 +124,7 @@ inline Uint32 get_pixel32( int x, int y, SDL_Surface *surface )
return (ccc_error);
}
*/
-
- return pixels[ ( y * surface->w ) + x ];
+ return ccc;
}
@@ -1033,7 +1035,7 @@ int stateLemming(struct gameInit *gInit){
to.x = x + i * (from.w + 2);
to.y = y;
from.y = buf[i] * (from.h);
- test_blit(src, &from, dst, &to);
+ test_blit(src, &from, dst, &to,0);
}
return 0;
}
@@ -1049,7 +1051,7 @@ int stateLemming(struct gameInit *gInit){
to.y=y-rect.h;
rect.w=cooldown->w;
- test_blit(cooldown, &rect, dst, &to);
+ test_blit(cooldown, &rect, dst, &to,0);
return 0;
}
@@ -1069,7 +1071,7 @@ int stateLemming(struct gameInit *gInit){
from.y = i * (from.h ) ;
to.x = x + (i%40)*16;
to.y = y + from.h * (i/40);
- test_blit(src, &from, dst, &to);
+ test_blit(src, &from, dst, &to,0);
//print_num(screen, src2, to.x + 20, to.y, i);
}
@@ -1098,7 +1100,7 @@ int stateLemming(struct gameInit *gInit){
to.x = x + i * (from.w);
to.y = y;
if(from.y!=-1){
- test_blit(src, &from, dst, &to);
+ test_blit(src, &from, dst, &to,0);
}
}
return 0;
@@ -1176,7 +1178,8 @@ int stateLemming(struct gameInit *gInit){
SDL_MapRGB( optimizedImage->format,
(cbg >> 16) & 0xff,
(cbg >> 8) & 0xff,
- (cbg & 0xff))
+ (cbg & 0xff)
+ )
);
}
//Libération de l'ancienne image
@@ -1195,6 +1198,7 @@ int stateLemming(struct gameInit *gInit){
char *temp;
char *filepath;
char *folderLem;
+ struct listeSimplementChainee *k=NULL;
temp = tabString_eMapStyle[gInit->mapI.map.style];
lt = strlen(temp);
@@ -1234,6 +1238,22 @@ int stateLemming(struct gameInit *gInit){
sprintf(filepath, "%s/%s%s%d.gif", folder,temp,"o_", i/2);
gInit->mapI.map.tabGif[i+cpt] = load_image(filepath,ccc_keyGif);
gInit->mapI.map.tabGif[i+1+cpt] = flipSurfaceUD_LR(load_image(filepath,ccc_keyGif),UD,ccc_keyGif);
+
+ k=gInit->o.lo;
+ while ( k !=NULL ) {
+ if(k->ID*2 == i){
+ k->data.po->img=malloc(sizeof(SDL_Surface*));
+ if(k->data.po->UD==0){
+ k->data.po->img=load_image(filepath,ccc_keyGif);
+ } else {
+ k->data.po->img=flipSurfaceUD_LR(load_image(filepath,ccc_keyGif),UD,ccc_keyGif);
+ }
+ }
+ k=k->next;
+ }
+
+
+
if((gInit->mapI.map.tabGif[i+cpt] == NULL)||(gInit->mapI.map.tabGif[i+1+cpt] == NULL)) {
//-DEBUG-printf("ERREUR load_file Objet: %s\n", filepath);
return(17);
@@ -1522,9 +1542,6 @@ int stateLemming(struct gameInit *gInit){
fclose(yyin);
//-DEBUG-printf("CLOSE 3\n");
- err=load_fields(folder, gInit, tabNum);
- if(err!=0){return err;}
-
//-DEBUG-printf("REVERSE t.lt\n");
gInit->t.lt=(struct listeSimplementChainee*)rev_listeO(gInit->t.lt);
//-DEBUG-printf("REVERSE o.lo\n");
@@ -1532,6 +1549,10 @@ int stateLemming(struct gameInit *gInit){
//-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;}
@@ -2066,7 +2087,7 @@ int stateLemming(struct gameInit *gInit){
}
if((w0 + x0 >LEVEL_WIDTH)||(h0 + y0 > LEVEL_HEIGHT)){return 0;}
-
+ //SDL_LockSurface(s);
for(j=0;j<h0;j+=stepScreenY){
if((y0+j)<0){continue;}
rect.y=MINIMAP_Y0+(j/stepScreenY)*sizeMiniMapPixel_Y;
@@ -2084,21 +2105,28 @@ int stateLemming(struct gameInit *gInit){
err=get_pixel32(x0+i,y0+j,s);
if(err==ccc_error){return 123;}
- test_FillRect(screen, &rect, err);
+ test_FillRect(pInterface, &rect, err,0);
}
}
+ //SDL_UnlockSurface(s);
//printf("cpt = %d\n",cpt);
return 0;
}
- int test_FillRect( SDL_Surface *t, SDL_Rect *to, Uint32 ccc){
+ int test_FillRect( SDL_Surface *t, SDL_Rect *to, Uint32 ccc, int choix){
+ if(choix==1){
+ SDL_LockSurface(t);
+ }
SDL_FillRect(t, to, ccc);
+ if(choix==1){
+ SDL_UnlockSurface(t);
+ }
return 0;
}
- int test_blit(SDL_Surface *spr,SDL_Rect *fr1,SDL_Surface *t,SDL_Rect *to1){
+ int test_blit(SDL_Surface *spr,SDL_Rect *fr1,SDL_Surface *t,SDL_Rect *to1, int choix){
/* int size;
void *temp_pixels = NULL;
@@ -2114,9 +2142,13 @@ int stateLemming(struct gameInit *gInit){
SDL_UnlockSurface(t);
SDL_UnlockSurface(spr);*/
-
-
+ if(choix==1){
+ SDL_LockSurface(t);
+ }
SDL_BlitSurface(spr,fr1, t,to1);
+ if(choix==1){
+ SDL_UnlockSurface(t);
+ }
/* SDL_LockSurface(spr);
memcpy(spr->pixels,temp_pixels,size);
SDL_UnlockSurface(spr);
@@ -2137,7 +2169,7 @@ int stateLemming(struct gameInit *gInit){
Uint32 ccc_temp3=0x00000000;
//FULL
if(mode==0){
- err=test_blit(spr,&from, t,&to);
+ err=test_blit(spr,&from, t,&to,0);
return err;
}
@@ -2287,7 +2319,7 @@ int stateLemming(struct gameInit *gInit){
SDL_UnlockSurface(t);
SDL_UnlockSurface(spr);
- test_blit(spr,&from, t,&to);
+ test_blit(spr,&from, t,&to,0);
SDL_LockSurface(spr);
memcpy(spr->pixels,temp_pixels,size);
@@ -2319,7 +2351,7 @@ int stateLemming(struct gameInit *gInit){
k=gInit->o.lo;
while ( k !=NULL ) {
- sf = gInit->mapI.map.tabGif[gInit->mapI.map.tiles*2+k->ID*2+k->data.po->UD+ADD_OBJ];
+ sf = k->data.po->img;
type=gInit->mapI.map.tabDataSprO[k->ID].type;
@@ -2360,8 +2392,12 @@ int stateLemming(struct gameInit *gInit){
// fin check
rStencil.x=0 ;
rStencil.y=objetAnim.y ;
- if((err=paint_manip(sf,rStencil,pSpr_Lem,offset,gInit->mapI.map.cmap.bgColor,ccc_keyGif,mode,NULL))!=0){
+ /* if((err=paint_manip(sf,rStencil,pSpr_Lem,offset,gInit->mapI.map.cmap.bgColor,ccc_keyGif,mode,NULL))!=0){
return err;
+ }*/
+ if ((err=test_blit(sf, &rStencil, pSpr_Lem, &offset,0)) != 0){
+ //-DEBUG-printf("ERREUR [%d] test_blit : ",err);
+ return err;
}
}
k=k->next;
@@ -2370,6 +2406,79 @@ int stateLemming(struct gameInit *gInit){
///FIN TEST: SPR
return 0;
}
+
+ int paint_objet_Init (struct gameInit *gInit){
+ SDL_Rect offset,objetAnim,rStencil;
+ SDL_Surface *sf;
+ struct listeSimplementChainee *k=NULL;
+ int err=0,i,of;
+ int type=0,size;
+ //int ox,oy;
+ //passage==0 => no dig
+ //passage==1 => rest
+ int passage;
+ int mode=0;
+ int yToH,xToW,fit,hf;
+ Uint32* temp_pixels= NULL;
+ //Uint32 color,color2,color3;
+ //int size;
+ //void *temp_pixels = NULL;
+
+ //DEBUT TEST: SPR
+ k=gInit->o.lo;
+ while ( k !=NULL ) {
+
+ sf = k->data.po->img;
+ type=gInit->mapI.map.tabDataSprO[k->ID].type;
+ of=gInit->mapI.map.tabDataSprO[k->ID].state;
+ hf=(sf->h/of);
+
+ mode=k->data.po->paintMode;
+
+ // check combi impossible
+ if((mode!=8)&&((type==3)||(type==4))){
+ //-DEBUG-printf("Construction impossible: mode!=%d(8) && type=%d(3 ou 4)\n",mode,type);
+ return 56;
+ }
+ if((mode==8)&&(type==5)){
+ //-DEBUG-printf("Construction impossible: mode==%d(8) && type=%d(5)\n",mode,type);
+ return 57;
+ }
+ // fin check
+ for(fit=0;fit<of;++fit){
+ for(yToH=0;yToH<hf;++yToH){
+ for(xToW=0;xToW<sf->w;++xToW){
+ // printf("x %d (%d) y %d (%d) fit %d (%d)\n",xToW,sf->w,yToH,hf,fit,of);
+ // ((Uint32 *)gInit->mapI.map.tabGif[gInit->mapI.map.tiles*2+k->ID*2+k->data.po->UD+ADD_OBJ]->pixels)[xToW+yToH+(hf*fit)]=0x0fff0f;
+ if((k->x+xToW < 0)||
+ (k->x+xToW > LEVEL_WIDTH)||
+ (k->y+yToH < 0)||
+ (k->y+yToH > LEVEL_HEIGHT)){
+ ((Uint32 *)k->data.po->img->pixels)[xToW+yToH*sf->w+(hf*fit*sf->w)]=ccc_keyGif;
+ //err=putPixel(temp_pixels,xToW,yToH,NULL);
+ //if(err!=0){return err;}
+ } else {
+ err=get_pixel32(k->x+xToW,k->y+yToH,pTerrain);
+ if(err==ccc_error){return 123;}
+ if(mode==4){
+ if(err!=gInit->mapI.map.cmap.bgColor){
+ ((Uint32 *)k->data.po->img->pixels)[xToW+yToH*sf->w+(hf*fit*sf->w)]=err; // ou err
+ }
+ }
+ if(mode==8){
+ if(err==gInit->mapI.map.cmap.bgColor){
+ ((Uint32 *)k->data.po->img->pixels)[xToW+yToH*sf->w+(hf*fit*sf->w)]=err; // ou err
+ }
+ }
+ }
+ }
+ }
+ }
+ k=k->next;
+ }
+ ///FIN TEST: SPR
+ return 0;
+ }
int paint_objet_stencil (struct gameInit *gInit, int cptFps){
SDL_Rect offset,objetAnim,rStencil;
@@ -2665,16 +2774,16 @@ int paint_lemming (struct gameInit *gInit, int cptFps){
rect.x=k->x+sf->w-fx-fs;
//putPixel(pStencil,k->x+sf->w-fx-fs,k->y+fy,ccc_lStopperLeft);
- test_FillRect(pStencil, &rect, ccc_lStopperLeft);
+ test_FillRect(pStencil, &rect, ccc_lStopperLeft,0);
rect.x=k->x+sf->w/2;
- test_FillRect(pStencil, &rect, ccc_lStopperRight);
+ test_FillRect(pStencil, &rect, ccc_lStopperRight,0);
//putPixel(pStencil,k->x+fx+fs,k->y+fy,ccc_lStopperRight);
break;
}
default:break;
}
- if ((res=test_blit(sf, &objetAnim, pSpr_Lem, &offset)) != 0){
+ if ((res=test_blit(sf, &objetAnim, pSpr_Lem, &offset,0)) != 0){
//-DEBUG-printf("ERREUR [%d] test_blit : ",res);
}
}
@@ -2776,7 +2885,7 @@ int findTerrain( struct gameInit *gInit,int x, int y, int x0){
to.y=screen->h-10;
to.w=600;
to.h=10;
- test_FillRect(screen, &to, ccc_black);
+ test_FillRect(screen, &to, ccc_black,0);
while(k != NULL){
sf=gInit->mapI.map.tabGif[test_O_UD(k->data.pt->modif)+k->ID*2+ADD_OBJ];
if( (x+15 <= k->x + sf->w)&&
@@ -2790,22 +2899,22 @@ int findTerrain( struct gameInit *gInit,int x, int y, int x0){
to.y=k->y;
to.w=sf->w;
to.h=1;
- test_FillRect(pStencil, &to, ccc_red);
+ test_FillRect(pStencil, &to, ccc_red,0);
to.x=k->x;
to.y=k->y;
to.w=1;
to.h=sf->h;
- test_FillRect(pStencil, &to, ccc_red);
+ test_FillRect(pStencil, &to, ccc_red,0);
to.x=k->x + sf->w - 1;
to.y=k->y;
to.w=1;
to.h=sf->h;
- test_FillRect(pStencil, &to, ccc_red);
+ test_FillRect(pStencil, &to, ccc_red,0);
to.x=k->x ;
to.y=k->y + sf->h - 1;
to.w=sf->w;
to.h=1;
- test_FillRect(pStencil, &to, ccc_red);
+ test_FillRect(pStencil, &to, ccc_red,0);
err=print_num(pStencil, gInit->mapI.map.tabGif[1], k->x + 2, k->y + 2, i);
if(err!=0){return err;}
@@ -2833,7 +2942,7 @@ int paint_cursor(SDL_Surface *dst1,SDL_Surface *dst2, SDL_Surface *src, int x, i
to.x = (y>LEVEL_HEIGHT)? x0 : x;
to.y = y;
if (y>LEVEL_HEIGHT){// cursor in pSpr_Lem
- test_blit(src, &from, dst2, &to);
+ test_blit(src, &from, dst2, &to,0);
} else {
k=gInit->l.ll;
while(k != NULL){
@@ -2874,16 +2983,16 @@ int paint_cursor(SDL_Surface *dst1,SDL_Surface *dst2, SDL_Surface *src, int x, i
k=k->next;
}
to.y -= 4;
- test_blit(src, &from, dst1, &to);
+ test_blit(src, &from, dst1, &to,0);
if(y+from.h>LEVEL_HEIGHT){
to.x = (f==1)? k->x-x + x0:x0;
to.y = (f==1)? k->y -4 :y -4;
- test_blit(src, &from, dst2, &to);
+ test_blit(src, &from, dst2, &to,0);
} else {
if(f==1){
to.x = k->x-x + x0;
to.y = k->y -4 ;
- test_blit(src, &from, dst2, &to);
+ test_blit(src, &from, dst2, &to,0);
}
}
}
@@ -2899,93 +3008,93 @@ int legende (struct gameInit *gInit){
//char* msg=NULL;
rStencil.x= 400;
- rStencil.y= LEVEL_HEIGHT + 1;
+ rStencil.y= 1;
rStencil.w= 10;
rStencil.h= 10;
- err=print_alpha(screen, gInit->mapI.map.tabGif[9], rStencil.x + 15,rStencil.y,"Terrain:");
+ err=print_alpha(pInterface, gInit->mapI.map.tabGif[9], rStencil.x + 15,rStencil.y,"Terrain:");
if(err!=0){return err;}
rStencil.y += decalY;
- test_FillRect(screen, &rStencil, ccc_tRemove);
- err=print_alpha(screen, gInit->mapI.map.tabGif[9], rStencil.x + 15,rStencil.y ,"Remove");
+ test_FillRect(pInterface, &rStencil, ccc_tRemove,0);
+ err=print_alpha(pInterface, gInit->mapI.map.tabGif[9], rStencil.x + 15,rStencil.y ,"Remove");
if(err!=0){return err;}
rStencil.y += decalY;
- test_FillRect(screen, &rStencil, ccc_tRemoveNoOverwrite);
- err=print_alpha(screen, gInit->mapI.map.tabGif[9], rStencil.x + 15,rStencil.y,"No Overwrite Remove");
+ test_FillRect(pInterface, &rStencil, ccc_tRemoveNoOverwrite,0);
+ err=print_alpha(pInterface, gInit->mapI.map.tabGif[9], rStencil.x + 15,rStencil.y,"No Overwrite Remove");
if(err!=0){return err;}
rStencil.y += decalY;
- test_FillRect(screen, &rStencil, ccc_tFull);
- err=print_alpha(screen, gInit->mapI.map.tabGif[9], rStencil.x + 15,rStencil.y,"Full");
+ test_FillRect(pInterface, &rStencil, ccc_tFull,0);
+ err=print_alpha(pInterface, gInit->mapI.map.tabGif[9], rStencil.x + 15,rStencil.y,"Full");
if(err!=0){return err;}
rStencil.y += decalY;
- test_FillRect(screen, &rStencil, ccc_tNoOverwrite);
- err=print_alpha(screen, gInit->mapI.map.tabGif[9], rStencil.x + 15,rStencil.y,"No Overwrite");
+ test_FillRect(pInterface, &rStencil, ccc_tNoOverwrite,0);
+ err=print_alpha(pInterface, gInit->mapI.map.tabGif[9], rStencil.x + 15,rStencil.y,"No Overwrite");
if(err!=0){return err;}
rStencil.y += decalY;
- test_FillRect(screen, &rStencil, ccc_tHidden);
- err=print_alpha(screen, gInit->mapI.map.tabGif[9], rStencil.x + 15,rStencil.y,"Hidden");
+ test_FillRect(pInterface, &rStencil, ccc_tHidden,0);
+ err=print_alpha(pInterface, gInit->mapI.map.tabGif[9], rStencil.x + 15,rStencil.y,"Hidden");
if(err!=0){return err;}
rStencil.y += decalY;
// object
rStencil.x = 30;
- rStencil.y = LEVEL_HEIGHT + 1;
- err=print_alpha(screen, gInit->mapI.map.tabGif[9], rStencil.x + 15,rStencil.y,"Objet:");
+ rStencil.y = 1;
+ err=print_alpha(pInterface, gInit->mapI.map.tabGif[9], rStencil.x + 15,rStencil.y,"Objet:");
if(err!=0){return err;}
rStencil.y += decalY;
- test_FillRect(screen, &rStencil, ccc_oPassive);
- err=print_alpha(screen, gInit->mapI.map.tabGif[9], rStencil.x + 15,rStencil.y,"Passive");
+ test_FillRect(pInterface, &rStencil, ccc_oPassive,0);
+ err=print_alpha(pInterface, gInit->mapI.map.tabGif[9], rStencil.x + 15,rStencil.y,"Passive");
if(err!=0){return err;}
rStencil.y += decalY;
- test_FillRect(screen, &rStencil, ccc_oNoDigLeft);
- err=print_alpha(screen, gInit->mapI.map.tabGif[9], rStencil.x + 15,rStencil.y,"No digging to the left");
+ test_FillRect(pInterface, &rStencil, ccc_oNoDigLeft,0);
+ err=print_alpha(pInterface, gInit->mapI.map.tabGif[9], rStencil.x + 15,rStencil.y,"No digging to the left");
if(err!=0){return err;}
rStencil.y += decalY;
- test_FillRect(screen, &rStencil, ccc_oNoDigRight);
- err=print_alpha(screen, gInit->mapI.map.tabGif[9], rStencil.x + 15,rStencil.y,"No digging to the right");
+ test_FillRect(pInterface, &rStencil, ccc_oNoDigRight,0);
+ err=print_alpha(pInterface, gInit->mapI.map.tabGif[9], rStencil.x + 15,rStencil.y,"No digging to the right");
if(err!=0){return err;}
rStencil.y += decalY;
- test_FillRect(screen, &rStencil, ccc_oExit);
- err=print_alpha(screen, gInit->mapI.map.tabGif[9], rStencil.x + 15,rStencil.y,"Exit");
+ test_FillRect(pInterface, &rStencil, ccc_oExit,0);
+ err=print_alpha(pInterface, gInit->mapI.map.tabGif[9], rStencil.x + 15,rStencil.y,"Exit");
if(err!=0){return err;}
rStencil.y += decalY;
- test_FillRect(screen, &rStencil, ccc_oEntry);
- err=print_alpha(screen, gInit->mapI.map.tabGif[9], rStencil.x + 15,rStencil.y,"Entry");
+ test_FillRect(pInterface, &rStencil, ccc_oEntry,0);
+ err=print_alpha(pInterface, gInit->mapI.map.tabGif[9], rStencil.x + 15,rStencil.y,"Entry");
if(err!=0){return err;}
rStencil.y += decalY;
- test_FillRect(screen, &rStencil, ccc_oUnknow);
- err=print_alpha(screen, gInit->mapI.map.tabGif[9], rStencil.x + 15,rStencil.y,"Unknow");
+ test_FillRect(pInterface, &rStencil, ccc_oUnknow,0);
+ err=print_alpha(pInterface, gInit->mapI.map.tabGif[9], rStencil.x + 15,rStencil.y,"Unknow");
if(err!=0){return err;}
rStencil.y += decalY;
- test_FillRect(screen, &rStencil, ccc_oTrapDrown);
- err=print_alpha(screen, gInit->mapI.map.tabGif[9], rStencil.x + 15,rStencil.y,"Trap which makes lemmings drown (water/quick sand/mud)");
+ test_FillRect(pInterface, &rStencil, ccc_oTrapDrown,0);
+ err=print_alpha(pInterface, gInit->mapI.map.tabGif[9], rStencil.x + 15,rStencil.y,"Trap which makes lemmings drown (water/quick sand/mud)");
if(err!=0){return err;}
rStencil.y += decalY;
- test_FillRect(screen, &rStencil, ccc_oTrapAndNoLem);
- err=print_alpha(screen, gInit->mapI.map.tabGif[9], rStencil.x + 15,rStencil.y,"Trap which replaces lemming with death animation");
+ test_FillRect(pInterface, &rStencil, ccc_oTrapAndNoLem,0);
+ err=print_alpha(pInterface, gInit->mapI.map.tabGif[9], rStencil.x + 15,rStencil.y,"Trap which replaces lemming with death animation");
if(err!=0){return err;}
rStencil.y += decalY;
- test_FillRect(screen, &rStencil, ccc_oTrapAndLem);
- err=print_alpha(screen, gInit->mapI.map.tabGif[9], rStencil.x + 15,rStencil.y,"Trap which triggers lemming death animation");
+ test_FillRect(pInterface, &rStencil, ccc_oTrapAndLem,0);
+ err=print_alpha(pInterface, gInit->mapI.map.tabGif[9], rStencil.x + 15,rStencil.y,"Trap which triggers lemming death animation");
if(err!=0){return err;}
rStencil.y += decalY + 2;
- err=print_alpha(screen, gInit->mapI.map.tabGif[9], rStencil.x +15 ,rStencil.y,"Steel:");
+ err=print_alpha(pInterface, gInit->mapI.map.tabGif[9], rStencil.x +15 ,rStencil.y,"Steel:");
if(err!=0){return err;}
rStencil.y += decalY;
- test_FillRect(screen, &rStencil, ccc_s);
- err=print_alpha(screen, gInit->mapI.map.tabGif[9], rStencil.x + 15,rStencil.y,"Indestructible terrain");
+ test_FillRect(pInterface, &rStencil, ccc_s,0);
+ err=print_alpha(pInterface, gInit->mapI.map.tabGif[9], rStencil.x + 15,rStencil.y,"Indestructible terrain");
if(err!=0){return err;}
return 0;
@@ -2998,7 +3107,7 @@ int paint_interface (struct gameInit *gInit){
SDL_Surface *sf;
from.x = 0;
- to.y = LEVEL_HEIGHT + INTER_BUTTON_Y;
+ to.y = INTER_BUTTON_Y;
for(i=0;i<NBR_BUTTON_LEMMING;++i){
@@ -3014,14 +3123,14 @@ int paint_interface (struct gameInit *gInit){
if(i+4 < 12){
n=gInit->mapI.paraMap[i+4];
- err=print_num(screen, gInit->mapI.map.tabGif[1], (to.x+7+(((n/10)>0)?0:5))+(sf->w*(2)), to.y-12,
+ err=print_num(pInterface, gInit->mapI.map.tabGif[1], (to.x+7+(((n/10)>0)?0:5))+(sf->w*(2)), to.y-12,
n);
if(err!=0){return err;}
}
- test_blit(sf, &from, screen, &to);
+ test_blit(sf, &from, pInterface, &to,0);
}
n=gInit->mapI.paraMap[0];
- err=print_num(screen, gInit->mapI.map.tabGif[1],INTER_BUTTON_X + 20 + (((n/10)>0)?0:5), to.y-12, n);
+ err=print_num(pInterface, gInit->mapI.map.tabGif[1],INTER_BUTTON_X + 20 + (((n/10)>0)?0:5), to.y-12, n);
if(err!=0){return err;}
return 0;
}
@@ -3208,31 +3317,35 @@ int lancement (){
// init level map (upper part of screen)
test_FillRect( pTerrain, &pTerrain->clip_rect,
- gInit.mapI.map.cmap.bgColor );
+ gInit.mapI.map.cmap.bgColor,0 );
// init interface (downner part of screen)
- test_FillRect( screen, &inter, ccc_black);
+ test_FillRect( screen, &inter, ccc_black,0);
cptFps=0;
gInit.cptGame[15]=0;
- test_FillRect( pStencil, NULL, ccc_bgStencil);
+ test_FillRect( pStencil, NULL, ccc_bgStencil,0);
//paint_terrain => pTerrain
err=paint_terrain(&gInit,0);
if(err!=0){return err;}
+
SDL_SetColorKey(pTerrain, SDL_SRCCOLORKEY|SDL_RLEACCEL, gInit.mapI.map.cmap.bgColor);
- test_blit(pStencil, NULL, pStencilFixe, NULL);
+ err=paint_objet_Init (&gInit);
+ if(err!=0){return err;}
+
+ test_blit(pStencil, NULL, pStencilFixe, NULL,0);
SDL_SetColorKey(pStencilFixe, SDL_SRCCOLORKEY, ccc_bgStencil);
//==>
//-->
err=paint_objet_stencil (&gInit,cptFps);
if(err!=0){return err;}
- test_blit(pStencil, NULL, pStencilFixe, NULL);
+ test_blit(pStencil, NULL, pStencilFixe, NULL,0);
//<--
//Tant que l'utilisateur n'a pas quitter
@@ -3280,13 +3393,14 @@ int lancement (){
}
}
- test_FillRect( pSpr_Lem, NULL, gInit.mapI.map.cmap.bgColor);
- test_blit(pTerrain, NULL, pSpr_Lem, NULL);
+ test_FillRect( pSpr_Lem, NULL, gInit.mapI.map.cmap.bgColor,0);
+ test_blit(pTerrain, NULL, pSpr_Lem, NULL,0);
- test_FillRect( screen, &inter, ccc_black);
+ test_FillRect( screen, &inter, ccc_black,0);
+ test_FillRect( pInterface, NULL , ccc_black,0);
- test_FillRect( pStencil, NULL, ccc_bgStencil);
- test_blit(pStencilFixe, NULL, pStencil, NULL);
+ test_FillRect( pStencil, NULL, ccc_bgStencil,0);
+ test_blit(pStencilFixe, NULL, pStencil, NULL,0);
// SPR => pSpr_Lem
err=paint_objet (&gInit,cptFps);
@@ -3311,6 +3425,7 @@ int lancement (){
err=legende (&gInit);
if(err!=0){return err;}
}
+ test_blit(pInterface, NULL , screen, &inter,0);
// CURSOR => pSpr_Lem, screen
if(paint_stencil==0){
@@ -3331,11 +3446,11 @@ int lancement (){
if(paint_stencil==0){
// printf("test %p\n",pSpr_Lem);
- test_blit(pSpr_Lem, &camera, screen, NULL);
+ test_blit(pSpr_Lem, &camera, screen, NULL,0);
err=miniMap (pSpr_Lem,mouseX+camera.x,mouseY+camera.y,0.10,0.10);//0.10,0.10); 5.,5.);
if( err != 0){ return err;}
} else {
- test_blit(pStencil, &camera, screen, NULL);
+ test_blit(pStencil, &camera, screen, NULL,0);
err=miniMap (pStencil,mouseX+camera.x,mouseY+camera.y,0.10,0.10);
if( err != 0){ return err;}
@@ -3353,13 +3468,13 @@ int lancement (){
}
++fps_count;
- /*
+
if (cptFps == 99999) {
//if(SDL_GetTicks()==240000){
//decalFps = 99;
quit=1;
}
- */
+
// limte fps
if(FPS<=decalFps){//-DEBUG-printf("BUG: FPS < 0 : (FPS %d - decalFps %d) < 0",FPS,decalFps);
@@ -3399,7 +3514,7 @@ int lancement (){
if(FPS<=decalFps){//-DEBUG-printf("BUG: FPS < 0 : (FPS %d - decalFps %d) < 0",FPS,decalFps);
return(43);
} else {
- temps = SDL_GetTicks();
+ //-DEBUG-temps = SDL_GetTicks();
//-DEBUG-printf("cptFps = %d, time: %ld:%ld:%ld \n",cptFps,temps/(1000*3600),(temps/(1000*60))%60,(temps/1000)%60);
}
cptFps++;
diff --git a/sdl-test/SDL_tuto/TestParserLemmingsLVL/genereTerrain.sh b/sdl-test/SDL_tuto/TestParserLemmingsLVL/genereTerrain.sh
index 993107e..b64287b 100755
--- a/sdl-test/SDL_tuto/TestParserLemmingsLVL/genereTerrain.sh
+++ b/sdl-test/SDL_tuto/TestParserLemmingsLVL/genereTerrain.sh
@@ -194,10 +194,10 @@ do
if [ $numObjetTest -ne 99 ]
then
if [ $typeObjet -eq "5" ]
- then mode=0
+ then mode=4
else
if [ $typeObjet -eq "6" ]
- then mode=0 #4
+ then mode=4
else
if [ $typeObjet -eq "7" ]
then mode=0
@@ -207,10 +207,10 @@ do
fi
else
if [ $typeObjet -eq "5" ]
- then mode=0
+ then mode=4
else
if [ $typeObjet -eq "6" ]
- then mode=0 #4
+ then mode=4
else
if [ $typeObjet -eq "7" ]
then mode=0
diff --git a/sdl-test/SDL_tuto/TestParserLemmingsLVL/parse_ini.yy b/sdl-test/SDL_tuto/TestParserLemmingsLVL/parse_ini.yy
index 99cbcc6..53215d4 100644
--- a/sdl-test/SDL_tuto/TestParserLemmingsLVL/parse_ini.yy
+++ b/sdl-test/SDL_tuto/TestParserLemmingsLVL/parse_ini.yy
@@ -38,10 +38,13 @@
#define MINIMAP_MX 210 //464
#define MINIMAP_MY 48 //120*/
+
#define MINIMAP_X0 420
-#define MINIMAP_Y0 325
+#define MINIMAP_Y0 5 //325
#define MINIMAP_MX 350
-#define MINIMAP_MY 175
+#define MINIMAP_MY 145 //175
+
+
const int INTER_BUTTON_X = 0;
const int INTER_BUTTON_Y = 50;
@@ -155,6 +158,7 @@
SDL_Surface *pTerrain = NULL; //Fond avec juste la map
SDL_Surface *pSpr_Lem = NULL; // Fond + lemmings + animations
SDL_Surface *screen = NULL; // Ecran via la caméra
+ SDL_Surface *pInterface = NULL; // Ecran du bas
SDL_Surface *pStencil= NULL; // Ecran Stencil
SDL_Surface *pStencilFixe= NULL; // Ecran Stencil Fixe
@@ -368,6 +372,7 @@
int UD; // upside down (0,1);
int paintMode;// paint modes: 8=VIS_ON_TERRAIN, 4=NO_OVERWRITE, 0=FULL (only one value possible)
int cptState; // count number of frame for an animation at once, default=0;
+ SDL_Surface *img; // image de l'objet; default=NULL;
};
struct paraSteel {
@@ -511,6 +516,8 @@
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 paint_objet (struct gameInit *gInit, int cptFps);
+
+ int paint_objet_Init (struct gameInit *gInit);
int paint_objet_stencil (struct gameInit *gInit, int cptFps);
@@ -548,9 +555,9 @@
int lancement();
- int test_blit(SDL_Surface *spr,SDL_Rect* from,SDL_Surface *t,SDL_Rect* to);
+ int test_blit(SDL_Surface *spr,SDL_Rect* from,SDL_Surface *t,SDL_Rect* to, int choix);
- int test_FillRect( SDL_Surface *t, SDL_Rect *to, Uint32 ccc);
+ int test_FillRect( SDL_Surface *t, SDL_Rect *to, Uint32 ccc, int choix);
int miniMap (SDL_Surface *s, int x0, int y0, float coefX, float coefY);
@@ -960,6 +967,7 @@ int main (int argc, char **argv)
{
int res,i,num,lt;
char *temp,*temp0;
+ long tempsi;
//Uint32 ctest;
//int j,k;
//argc=3;
@@ -1020,7 +1028,9 @@ int main (int argc, char **argv)
}}}*/
res=lancement();
+ tempsi = SDL_GetTicks();
printf("code retour %d\n",res);
+ printf("Duree d'execution: %ld:%ld:%ld \n",tempsi/(1000*3600),(tempsi/(1000*60))%60,(tempsi/1000)%60);
//fclose(yyin); fait dans lancement
return res;