summaryrefslogtreecommitdiff
path: root/sdl-test
diff options
context:
space:
mode:
authorDamien Appert <dappert>2010-11-08 14:42:23 +0000
committerDamien Appert <dappert>2010-11-08 14:42:23 +0000
commita4bde858ed20050c43e0d3fb8023562bc3b87df4 (patch)
tree8ff1414ea53668e46fcd3fc34ce60a3a96285451 /sdl-test
parent2181e6c1b7c9bab930a545b2d00b802a5552c91b (diff)
download2010-netlemmings-a4bde858ed20050c43e0d3fb8023562bc3b87df4.tar.gz
2010-netlemmings-a4bde858ed20050c43e0d3fb8023562bc3b87df4.tar.bz2
2010-netlemmings-a4bde858ed20050c43e0d3fb8023562bc3b87df4.zip
minimap + boost FPS_II
git-svn-id: file:///var/svn/2010-netlemmings/trunk@144 077b3477-7977-48bd-8428-443f22f7bfda
Diffstat (limited to 'sdl-test')
-rw-r--r--sdl-test/SDL_tuto/TestParserLemmingsLVL/Makefile2
-rw-r--r--sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_integrees.c10
-rw-r--r--sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c619
-rw-r--r--sdl-test/SDL_tuto/TestParserLemmingsLVL/parse_ini.yy18
4 files changed, 373 insertions, 276 deletions
diff --git a/sdl-test/SDL_tuto/TestParserLemmingsLVL/Makefile b/sdl-test/SDL_tuto/TestParserLemmingsLVL/Makefile
index 1451da4..2850f3d 100644
--- a/sdl-test/SDL_tuto/TestParserLemmingsLVL/Makefile
+++ b/sdl-test/SDL_tuto/TestParserLemmingsLVL/Makefile
@@ -4,7 +4,7 @@ TARGET = main
OBJECTS =
CFLAGS = -Wall -g -pg -I/usr/include/SDL -L/usr/lib
-LIBS = -lSDL -lSDL_image -lfl
+LIBS = -lSDL -lSDL_image -lSDL_gfx -lfl
CC = gcc
all: $(TARGET)
diff --git a/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_integrees.c b/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_integrees.c
index 0dcae5d..493f16a 100644
--- a/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_integrees.c
+++ b/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_integrees.c
@@ -9,7 +9,7 @@ int init()
}
//Mise en place de l'écran
- screen = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_HWSURFACE | SDL_DOUBLEBUF );
+ screen = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE);
//-DEBUG-printf("DEBUG ludo : screen->w==%i, screen->h==%i\n", screen->w, screen->h);
//S'il y a une erreur lors de la mise en place de l'écran
@@ -18,13 +18,13 @@ int init()
return 2;
}
- pTerrain = SDL_CreateRGBSurface(SDL_HWSURFACE, LEVEL_WIDTH, LEVEL_HEIGHT,
+ pTerrain = SDL_CreateRGBSurface(SDL_SWSURFACE, LEVEL_WIDTH, LEVEL_HEIGHT,
SCREEN_BPP,0,0,0,0);//(ccc_black>> 16) & 0xff, (ccc_black>> 8)&0xff,(ccc_black& 0xff),0);
if( pTerrain == NULL ) {
return 3;
}
- pSpr_Lem = SDL_CreateRGBSurface(SDL_HWSURFACE, LEVEL_WIDTH, LEVEL_HEIGHT,
+ pSpr_Lem = SDL_CreateRGBSurface(SDL_SWSURFACE, LEVEL_WIDTH, LEVEL_HEIGHT,
SCREEN_BPP,0,0,0,0);
if( pSpr_Lem == NULL ) {
@@ -43,9 +43,9 @@ int init()
return 3;
}
- pInterface = SDL_CreateRGBSurface(SDL_HWSURFACE, SCREEN_WIDTH, INTERFACE_HEIGHT,
+ pInterface = SDL_CreateRGBSurface(SDL_SWSURFACE, SCREEN_WIDTH, INTERFACE_HEIGHT,
SCREEN_BPP,0,0,0,0);
- if( pStencil == NULL ) {
+ if( pInterface == NULL ) {
return 3;
}
//Mise en place de la barre caption
diff --git a/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c b/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c
index 2d94853..ab79f77 100644
--- a/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c
+++ b/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c
@@ -449,7 +449,7 @@ int stateLemming(struct gameInit *gInit){
if(paint_bomber(k->x,k->y,lw,gInit->mapI.map.tabGif[2],pSpr_Lem,(k->data.pl->cptBoom/FPS +1))!=0){return 99;}
}
}
-
+
flip = 0;
//flipDirBorder
if (k->data.pl->dir==0) {//left
@@ -1179,7 +1179,7 @@ int stateLemming(struct gameInit *gInit){
(cbg >> 16) & 0xff,
(cbg >> 8) & 0xff,
(cbg & 0xff)
- )
+ )
);
}
//Libération de l'ancienne image
@@ -1238,22 +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;
- }
-
-
-
+
+ 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);
@@ -1513,18 +1513,18 @@ int stateLemming(struct gameInit *gInit){
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;
+ 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);
@@ -1702,6 +1702,9 @@ int stateLemming(struct gameInit *gInit){
// xPos
gInit->mapI.xPos=0;
+ //miniMap
+ gInit->mapI.miniMapLem=NULL;
+
//MaxFallDistance
gInit->mapI.nbrEntry=0;
gInit->mapI.MaxFallDistance = 126;
@@ -2019,12 +2022,46 @@ int stateLemming(struct gameInit *gInit){
return 0;
}
+ int miniMapLemming (struct gameInit *gInit){
+
+ int i,j,stepScreenX,stepScreenY,sizeMiniMapPixel_X,sizeMiniMapPixel_Y,w0,h0,x,y;
+ SDL_Rect rect;
+ SDL_Rect to;
+ Uint32 err;
+
+ //int cpt=0;
+
+ gInit->mapI.miniMapLem=SDL_CreateRGBSurface(SDL_SWSURFACE,
+ MINIMAPLEM_MX, MINIMAPLEM_MY,
+ SCREEN_BPP,0,0,0,0);
+
+ test_FillRect(gInit->mapI.miniMapLem,NULL,0, 0);
+
+ stepScreenX=pStencil->w/MINIMAPLEM_MX;
+ stepScreenY=pStencil->h/MINIMAPLEM_MY;
+
+ for(j=0;j<pStencil->h;j+=stepScreenY){
+ for(i=0;i<pStencil->w;i+=stepScreenX){
+ if(((i/stepScreenX)<MINIMAPLEM_MX)&&((j/stepScreenY)<MINIMAPLEM_MY)){
+ err=get_pixel32(i,j,pStencil);
+ if(err==ccc_error){return 123;}
+
+ err=putPixel(gInit->mapI.miniMapLem,i/stepScreenX,j/stepScreenY, err);
+ if(err!=0){return err;}
+ }
+ }
+ }
+
+ //printf("cpt = %d\n",cpt);
+ return 0;
+ }
int miniMap (SDL_Surface *s, int x0, int y0, float coefX, float coefY){
int i,j,stepScreenX,stepScreenY,sizeMiniMapPixel_X,sizeMiniMapPixel_Y,w0,h0,x,y;
SDL_Rect rect;
+ SDL_Rect to;
Uint32 err;
//int cpt=0;
@@ -2087,6 +2124,23 @@ int stateLemming(struct gameInit *gInit){
}
if((w0 + x0 >LEVEL_WIDTH)||(h0 + y0 > LEVEL_HEIGHT)){return 0;}
+
+ /*
+ // essaie avec rotozoom
+ rect.x=x0;
+ rect.y=y0;
+ rect.w=w0;
+ rect.h=h0;
+ to.x=MINIMAP_X0;
+ to.y=MINIMAP_Y0;
+ to.w=MINIMAP_MX;
+ to.h=MINIMAP_MY;
+ test_blit(rotozoomSurfaceXY(s,0,coefX,coefY,0),&rect,pInterface,&to, 0);
+ //SDL_Surface *rotozoomSurfaceXY(s,0,coefX,coefY,1);
+ */
+
+
+
//SDL_LockSurface(s);
for(j=0;j<h0;j+=stepScreenY){
if((y0+j)<0){continue;}
@@ -2146,7 +2200,7 @@ int stateLemming(struct gameInit *gInit){
SDL_LockSurface(t);
}
SDL_BlitSurface(spr,fr1, t,to1);
- if(choix==1){
+ if(choix==1){
SDL_UnlockSurface(t);
}
/* SDL_LockSurface(spr);
@@ -2286,7 +2340,8 @@ int stateLemming(struct gameInit *gInit){
}*/
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);
+ //-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)) {
((Uint32 *)spr->pixels)[(from.y+j)*spr->w+from.x+i]=ccc_t;//spr->format->colorkey;
} else {
@@ -2392,12 +2447,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;
+ //-DEBUG-printf("ERREUR [%d] test_blit : ",err);
+ return err;
}
}
k=k->next;
@@ -2406,8 +2461,8 @@ int stateLemming(struct gameInit *gInit){
///FIN TEST: SPR
return 0;
}
-
- int paint_objet_Init (struct gameInit *gInit){
+
+ int paint_objet_Init (struct gameInit *gInit){
SDL_Rect offset,objetAnim,rStencil;
SDL_Surface *sf;
struct listeSimplementChainee *k=NULL;
@@ -2425,57 +2480,57 @@ int stateLemming(struct gameInit *gInit){
//void *temp_pixels = NULL;
//DEBUT TEST: SPR
- k=gInit->o.lo;
- while ( k !=NULL ) {
+ 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);
+ 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;
+ 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
- }
- }
+ // 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;
}
+ k=k->next;
+ }
///FIN TEST: SPR
return 0;
}
@@ -2498,192 +2553,192 @@ int stateLemming(struct gameInit *gInit){
while ( k !=NULL ) {
//sf = gInit->mapI.map.tabGif[gInit->mapI.map.tiles*2+k->ID*2+k->data.po->UD+ADD_OBJ];
-
+
type=gInit->mapI.map.tabDataSprO[k->ID].type;
-
+
if (type>=3&&type<=8){
- cptSteel=0;
- for(i=0;i<gInit->mapI.map.tilesObjet;++i){
- if(i==k->ID){break;}
- if ((gInit->mapI.map.tabDataSprO[i].type)>=3 && (gInit->mapI.map.tabDataSprO[i].type)<=8){
- cptSteel++;
+ cptSteel=0;
+ for(i=0;i<gInit->mapI.map.tilesObjet;++i){
+ if(i==k->ID){break;}
+ if ((gInit->mapI.map.tabDataSprO[i].type)>=3 && (gInit->mapI.map.tabDataSprO[i].type)<=8){
+ cptSteel++;
+ }
}
- }
-
- //printf("k->ID %d cptSteel %d type %d \n",k->ID,cptSteel,type);
- sf = gInit->mapI.map.tabGif[gInit->mapI.map.tiles*2+gInit->mapI.map.tilesObjet*2+cptSteel*2+k->data.po->UD+ADD_OBJ];
- offset.x = k->x;
- offset.y = k->y;
+ //printf("k->ID %d cptSteel %d type %d \n",k->ID,cptSteel,type);
+ sf = gInit->mapI.map.tabGif[gInit->mapI.map.tiles*2+gInit->mapI.map.tilesObjet*2+cptSteel*2+k->data.po->UD+ADD_OBJ];
- //of=gInit->mapI.map.tabDataSprO[k->ID].state;
+ offset.x = k->x;
+ offset.y = k->y;
- objetAnim.x = 0;
- objetAnim.h = sf->h;///of;
- objetAnim.w = sf->w;
- objetAnim.y = 0;/*(anim_objet(
- gInit->mapI.map.tabDataSprO[k->ID].anim,
- type,
- cptFps,
- of,
- &k->data.po->cptState,
- gInit)
- )*(objetAnim.h);*/
-
- switch(type){
- case 3://no digging to the left
- ccc_temp=ccc_oNoDigLeft;break;
- case 4://no digging to the right
- ccc_temp=ccc_oNoDigRight;break;
- case 5://trap which makes lemmings drown (water/quick sand/mud)
- ccc_temp=ccc_oTrapDrown;break;
- case 6://trap which replaces lemming with death animation
- ccc_temp=ccc_oTrapAndNoLem;break;
- case 7://trap which triggers lemming death animation
- ccc_temp=ccc_oTrapAndLem;break;
- case 8://exit
- ccc_temp=ccc_oExit;break;
- default: //-DEBUG-printf("BUG: bad algo == type = %d\n",type);
- return 45;
- }
-
- if((err=paint_manip(sf,objetAnim,pStencil,offset,ccc_temp,ccc_keyGif,19,NULL))!=0){
+ //of=gInit->mapI.map.tabDataSprO[k->ID].state;
+
+ objetAnim.x = 0;
+ objetAnim.h = sf->h;///of;
+ objetAnim.w = sf->w;
+ objetAnim.y = 0;/*(anim_objet(
+ gInit->mapI.map.tabDataSprO[k->ID].anim,
+ type,
+ cptFps,
+ of,
+ &k->data.po->cptState,
+ gInit)
+ )*(objetAnim.h);*/
+
+ switch(type){
+ case 3://no digging to the left
+ ccc_temp=ccc_oNoDigLeft;break;
+ case 4://no digging to the right
+ ccc_temp=ccc_oNoDigRight;break;
+ case 5://trap which makes lemmings drown (water/quick sand/mud)
+ ccc_temp=ccc_oTrapDrown;break;
+ case 6://trap which replaces lemming with death animation
+ ccc_temp=ccc_oTrapAndNoLem;break;
+ case 7://trap which triggers lemming death animation
+ ccc_temp=ccc_oTrapAndLem;break;
+ case 8://exit
+ ccc_temp=ccc_oExit;break;
+ default: //-DEBUG-printf("BUG: bad algo == type = %d\n",type);
+ return 45;
+ }
+
+ if((err=paint_manip(sf,objetAnim,pStencil,offset,ccc_temp,ccc_keyGif,19,NULL))!=0){
return err;
}
-
+
}
- /* if(type==8){
- rStencil.w=objetAnim.w/8;
- rStencil.x=k->x+objetAnim.w/2-rStencil.w/2 -1 ;
- rStencil.y=k->y ;
- rStencil.h=objetAnim.h;
- } else {
- if(type==6){
+ /* if(type==8){
+ rStencil.w=objetAnim.w/8;
+ rStencil.x=k->x+objetAnim.w/2-rStencil.w/2 -1 ;
+ rStencil.y=k->y ;
+ rStencil.h=objetAnim.h;
+ } else {
+ if(type==6){
rStencil.x=k->x+objetAnim.w/2-6;
rStencil.y=k->y;
rStencil.w=10;
rStencil.h=objetAnim.h;
- } else {
+ } else {
rStencil.x=k->x;
rStencil.y=k->y;
rStencil.w=objetAnim.w;
rStencil.h=objetAnim.h;
- }
- }
+ }
+ }
- mode=k->data.po->paintMode;
+ 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;
+ //-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;
+ //-DEBUG-printf("Construction impossible: mode==%d(8) && type=%d(5)\n",mode,type);
+ return 57;
}
// fin check
if(type!=4&&type!=3){
- if(type==5){
- rStencil.y=k->y+(rStencil.h/6);
- //rStencil.h=(rStencil.h/6 + (rStencil.h/6)%6)*5;
- rStencil.h=10;
- }
- switch(type){
- case 0://passive
- test_FillRect(pStencil, &rStencil, ccc_oPassive);break;
- case 5://trap which makes lemmings drown (water/quick sand/mud)
- test_FillRect(pStencil, &rStencil, ccc_oTrapDrown);break;
- case 6:{//trap which replaces lemming with death animation
- --objetAnim.h;
- if((err=paint_manip(sf,objetAnim,pStencil,offset,ccc_oTrapAndNoLem,ccc_keyGif,19,NULL))!=0){
- return err;
- }
- ++objetAnim.h;
- //test_FillRect(pStencil, &rStencil, ccc_oTrapAndNoLem);
- break;
- }
- case 7:{//trap which triggers lemming death animation
- //test_FillRect(pStencil, &rStencil, ccc_oTrapAndLem);break;
- for(i=0;i<of;++i){
- k->data.po->cptState=i;
- objetAnim.y = (anim_objet(
- gInit->mapI.map.tabDataSprO[k->ID].anim,
- type,
- i*ANIM_STEP_FPS,
- of,
- &k->data.po->cptState,
- gInit)
- )*(objetAnim.h);
-
- if((err=paint_manip(sf,objetAnim,pStencil,offset,ccc_oTrapAndLem,ccc_keyGif,19,NULL))!=0){
- return err;
- }
- }
- k->data.po->cptState=0;
- break;
- }
- case 8://exit
- test_FillRect(pStencil, &rStencil, ccc_oExit);break;
- case 32://entry
- test_FillRect(pStencil, &rStencil, ccc_oEntry);
- break;
- default:test_FillRect(pStencil, &rStencil, ccc_oUnknow);break;
- }
- switch(mode){
- case 0:break;// FULL
- case 4: {//No Overwrite
- test_blit(pStencilFixe, &rStencil, pStencil, &rStencil);
- break;
- }
- case 8: break;//Vis On Terrain
- default:{//-DEBUG-printf("BUG: value is not 8 4 or 0 : %d \n",mode);
- return(36);}
- }
+ if(type==5){
+ rStencil.y=k->y+(rStencil.h/6);
+ //rStencil.h=(rStencil.h/6 + (rStencil.h/6)%6)*5;
+ rStencil.h=10;
}
- if(mode==8&&(type==3||type==4)){
- for(oy=k->y;oy<rStencil.h+k->y;oy+=1){
-
- if(oy<0) {oy=-1;continue;}
- if(oy>pSpr_Lem->h){break;}
- if(oy>=LEVEL_HEIGHT) {break;}
-
- if(sf->pixels==NULL){break;}
-
- for(ox=k->x;ox<rStencil.w+k->x;ox+=1){
-
- if(ox<0) {ox=-1;continue;}
- if(ox>pSpr_Lem->w){break;}
- if(ox>=LEVEL_WIDTH) {break;}
-
- //if(temp_pixels==NULL){break;}
- //memcpy(sf->pixels,temp_pixels,size);
- color2 = get_pixel32(objetAnim.x+ox-k->x,objetAnim.y+oy-k->y,sf);
- if(color2==ccc_error){return 253;}
- // NO DIG
- color = get_pixel32(ox,oy,pStencil);
- //error
- if(color==ccc_error){return 254;}
- // background
- if(color==ccc_bgStencil){continue;}
- // objet
- if((color&0xbb)==0xbb){continue;}
- // pixel transparency in object.gif
- if(type==3){
- err=putPixel(pStencil,ox,oy,ccc_oNoDigLeft);
- if(err!=0){return err;}
- } else {
- err=putPixel(pStencil,ox,oy,ccc_oNoDigRight);
- if(err!=0){return err;}
- }
+ switch(type){
+ case 0://passive
+ test_FillRect(pStencil, &rStencil, ccc_oPassive);break;
+ case 5://trap which makes lemmings drown (water/quick sand/mud)
+ test_FillRect(pStencil, &rStencil, ccc_oTrapDrown);break;
+ case 6:{//trap which replaces lemming with death animation
+ --objetAnim.h;
+ if((err=paint_manip(sf,objetAnim,pStencil,offset,ccc_oTrapAndNoLem,ccc_keyGif,19,NULL))!=0){
+ return err;
+ }
+ ++objetAnim.h;
+ //test_FillRect(pStencil, &rStencil, ccc_oTrapAndNoLem);
+ break;
+ }
+ case 7:{//trap which triggers lemming death animation
+ //test_FillRect(pStencil, &rStencil, ccc_oTrapAndLem);break;
+ for(i=0;i<of;++i){
+ k->data.po->cptState=i;
+ objetAnim.y = (anim_objet(
+ gInit->mapI.map.tabDataSprO[k->ID].anim,
+ type,
+ i*ANIM_STEP_FPS,
+ of,
+ &k->data.po->cptState,
+ gInit)
+ )*(objetAnim.h);
+
+ if((err=paint_manip(sf,objetAnim,pStencil,offset,ccc_oTrapAndLem,ccc_keyGif,19,NULL))!=0){
+ return err;
+ }
+ }
+ k->data.po->cptState=0;
+ break;
+ }
+ case 8://exit
+ test_FillRect(pStencil, &rStencil, ccc_oExit);break;
+ case 32://entry
+ test_FillRect(pStencil, &rStencil, ccc_oEntry);
+ break;
+ default:test_FillRect(pStencil, &rStencil, ccc_oUnknow);break;
+ }
+ switch(mode){
+ case 0:break;// FULL
+ case 4: {//No Overwrite
+ test_blit(pStencilFixe, &rStencil, pStencil, &rStencil);
+ break;
+ }
+ case 8: break;//Vis On Terrain
+ default:{//-DEBUG-printf("BUG: value is not 8 4 or 0 : %d \n",mode);
+ return(36);}
+ }
+ }
+ if(mode==8&&(type==3||type==4)){
+ for(oy=k->y;oy<rStencil.h+k->y;oy+=1){
+
+ if(oy<0) {oy=-1;continue;}
+ if(oy>pSpr_Lem->h){break;}
+ if(oy>=LEVEL_HEIGHT) {break;}
+
+ if(sf->pixels==NULL){break;}
+
+ for(ox=k->x;ox<rStencil.w+k->x;ox+=1){
+
+ if(ox<0) {ox=-1;continue;}
+ if(ox>pSpr_Lem->w){break;}
+ if(ox>=LEVEL_WIDTH) {break;}
+
+ //if(temp_pixels==NULL){break;}
+ //memcpy(sf->pixels,temp_pixels,size);
+ color2 = get_pixel32(objetAnim.x+ox-k->x,objetAnim.y+oy-k->y,sf);
+ if(color2==ccc_error){return 253;}
+ // NO DIG
+ color = get_pixel32(ox,oy,pStencil);
+ //error
+ if(color==ccc_error){return 254;}
+ // background
+ if(color==ccc_bgStencil){continue;}
+ // objet
+ if((color&0xbb)==0xbb){continue;}
+ // pixel transparency in object.gif
+ if(type==3){
+ err=putPixel(pStencil,ox,oy,ccc_oNoDigLeft);
+ if(err!=0){return err;}
+ } else {
+ err=putPixel(pStencil,ox,oy,ccc_oNoDigRight);
+ if(err!=0){return err;}
}
}
- //}
+ }
+ //}
}//FIN ELSE MODE
*/
- k=k->next;
+ k=k->next;
}
///FIN TEST: SPR
return 0;
@@ -3257,14 +3312,16 @@ int lancement (){
int err=0;
//Ce qui va nous permettre de quitter
int quit = 0;
- SDL_Rect camera,inter;
+ SDL_Rect camera,inter,miniMapR,test;
int mouseX,mouseY=0;
- long tick,temps=0;
- float fps = 0.0;
- int fps_count = 0;
- int fps_start = 0;
- int decalFps = 0;
-
+ long tick,temps=0;
+ float fps = 0.0;
+ int fps_count = 0;
+ int fps_start = 0;
+ int decalFps = 0;
+ float zoomX=0.10;
+ float zoomY=0.10;
+ int switchMiniMapMode=0;
//La structure d'evenement
SDL_Event event;
event.type=0;
@@ -3279,6 +3336,11 @@ int lancement (){
camera.x=0;
camera.y=0;
+ miniMapR.x= MINIMAPLEM_X0;
+ miniMapR.y= MINIMAPLEM_Y0;
+ miniMapR.w= MINIMAPLEM_MX;
+ miniMapR.h= MINIMAPLEM_MY;
+
struct gameInit gInit;
// constructor ...
@@ -3304,10 +3366,13 @@ int lancement (){
err=creationLemming(&gInit);
if(err!=0){return err;}
+ SDL_WM_SetCaption( gInit.mapI.name , NULL );
+
mouseX = gInit.mapI.xPos;
camera.x=gInit.mapI.xPos;
camera.w=screen->w;
camera.h=screen->h;
+
inter.x=0;
inter.y=LEVEL_HEIGHT;
inter.w=SCREEN_WIDTH;
@@ -3333,14 +3398,17 @@ int lancement (){
err=paint_terrain(&gInit,0);
if(err!=0){return err;}
+ err=miniMapLemming(&gInit);
+ if(err!=0){return err;}
SDL_SetColorKey(pTerrain, SDL_SRCCOLORKEY|SDL_RLEACCEL, gInit.mapI.map.cmap.bgColor);
+
err=paint_objet_Init (&gInit);
if(err!=0){return err;}
test_blit(pStencil, NULL, pStencilFixe, NULL,0);
- SDL_SetColorKey(pStencilFixe, SDL_SRCCOLORKEY, ccc_bgStencil);
+ SDL_SetColorKey(pStencilFixe, SDL_SRCCOLORKEY|SDL_RLEACCEL, ccc_bgStencil);
//==>
//-->
err=paint_objet_stencil (&gInit,cptFps);
@@ -3363,6 +3431,21 @@ int lancement (){
case SDLK_PAGEUP : if(decalFps>0){decalFps -=1;}break;
case SDLK_PAGEDOWN : if(decalFps<(FPS-1)){decalFps +=1;}break;
case SDLK_w : paint_stencil = (paint_stencil==0)? 1 : 0 ; break;
+ case SDLK_x : switchMiniMapMode= (switchMiniMapMode==0)? 1 : ((switchMiniMapMode==1)? 2 : ((switchMiniMapMode==2)? 3 : 0)) ;break;
+ case SDLK_p :{
+ zoomX=((zoomX >= 1. )? zoomX + 1. : zoomX + 0.1 );
+ zoomY=((zoomY >= 1. )? zoomY + 1. : zoomY + 0.1 );
+ if(zoomX > 10.) {zoomX=10.;}
+ if(zoomY > 10.) {zoomY=10.;}
+ break;
+ }
+ case SDLK_m :{
+ zoomX=((zoomX > 1. )? zoomX - 1. : zoomX - 0.1 );
+ zoomY=((zoomY > 1. )? zoomY - 1. : zoomY - 0.1 );
+ if(zoomX <= 0.) {zoomX=0.1;}
+ if(zoomY <= 0.) {zoomY=0.1;}
+ break;
+ }
case SDLK_ESCAPE : quit = 1; break;
default:break;
}
@@ -3425,7 +3508,6 @@ 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){
@@ -3444,18 +3526,29 @@ int lancement (){
//get_pixel32( event.motion.x + camera.x , event.motion.y, screen );
- if(paint_stencil==0){
- // printf("test %p\n",pSpr_Lem);
- 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,0);
- err=miniMap (pStencil,mouseX+camera.x,mouseY+camera.y,0.10,0.10);
- if( err != 0){ return err;}
+ if(switchMiniMapMode==2){
+ if(paint_stencil==0){
+ // printf("test %p\n",pSpr_Lem);
+ test_blit(pSpr_Lem, &camera, screen, NULL,0);
+ err=miniMap (pSpr_Lem,mouseX+camera.x,mouseY+camera.y,zoomX,zoomY);//0.10,0.10); 5.,5.);
+ if( err != 0){ return err;}
+ } else {
+ test_blit(pStencil, &camera, screen, NULL,0);
+ err=miniMap (pStencil,mouseX+camera.x,mouseY+camera.y,zoomX,zoomY);
+ if( err != 0){ return err;}
+ }} else {
+ if(paint_stencil==0){
+ // printf("test %p\n",pSpr_Lem);
+ test_blit(pSpr_Lem, &camera, screen, NULL,0);
+ test_blit(gInit.mapI.miniMapLem,NULL , pInterface, &miniMapR,0);
+ } else {
+ test_blit(pStencil, &camera, screen, NULL,0);
+ test_blit(gInit.mapI.miniMapLem,NULL , pInterface, &miniMapR,0);
+ }
- }
+ }
+ test_blit(pInterface, NULL , screen, &inter,0);
/* FPS counter */
//-DEBUG-printf("(tick %ld > fps_start %d +500)\n",tick,fps_start);
@@ -3468,13 +3561,13 @@ int lancement (){
}
++fps_count;
-
- if (cptFps == 99999) {
- //if(SDL_GetTicks()==240000){
- //decalFps = 99;
- quit=1;
+
+ 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);
@@ -3521,11 +3614,11 @@ int lancement (){
//quit = 1;
-}
+ }
-//On libère les images et on quitte SDL
-err=clean_up();
-if(err!=0){return err;}
+ //On libère les images et on quitte SDL
+ err=clean_up();
+ if(err!=0){return err;}
-return 0;
-}
+ return 0;
+ }
diff --git a/sdl-test/SDL_tuto/TestParserLemmingsLVL/parse_ini.yy b/sdl-test/SDL_tuto/TestParserLemmingsLVL/parse_ini.yy
index 53215d4..fca0945 100644
--- a/sdl-test/SDL_tuto/TestParserLemmingsLVL/parse_ini.yy
+++ b/sdl-test/SDL_tuto/TestParserLemmingsLVL/parse_ini.yy
@@ -3,6 +3,7 @@
#include "SDL/SDL.h"
#include "SDL/SDL_image.h"
+#include "SDL/SDL_rotozoom.h"
#include <sys/types.h>
#include <dirent.h>
@@ -25,24 +26,24 @@
const int TIME_WAIT_TRAP_START = 15000; // milliseconde
- const int INTERFACE_HEIGHT = 150;//200;
+ const int INTERFACE_HEIGHT = 180;//180;
//Les attributs de l'écran (640 * 480)
const int SCREEN_WIDTH = 800;//1280
const int SCREEN_HEIGHT = 500; // 480 //SCREEN_HEIGHT = LEVEL_HEIGHT + INTERFACE_HEIGHT + 30;
const int SCREEN_BPP = 32;
//MINIMAP
- /*
-#define MINIMAP_X0 420 //636
-#define MINIMAP_Y0 365
-#define MINIMAP_MX 210 //464
-#define MINIMAP_MY 48 //120*/
+
+#define MINIMAPLEM_X0 420 //636
+#define MINIMAPLEM_Y0 45
+#define MINIMAPLEM_MX 210 //464
+#define MINIMAPLEM_MY 48 //120
#define MINIMAP_X0 420
#define MINIMAP_Y0 5 //325
#define MINIMAP_MX 350
-#define MINIMAP_MY 145 //175
+#define MINIMAP_MY 175 //175
@@ -355,6 +356,7 @@
char* name; // map name; default=NULL;
int paraMap[IDENT_COUNT]; // some parameter of this map
int xPos; // camera started position
+ SDL_Surface *miniMapLem; // image de jeu ; default=NULL;
int MaxFallDistance; // max pixel lemming fall before died;default=0;
int nuke; // hiroshima= 1; default =0;
int nbrEntry; // number of entry in this map; default=0;
@@ -560,6 +562,8 @@
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);
+
+ int miniMapLemming (struct gameInit *gInit);
int paint_stencil=0;