diff options
author | Damien Appert <dappert> | 2010-11-18 14:42:37 +0000 |
---|---|---|
committer | Damien Appert <dappert> | 2010-11-18 14:42:37 +0000 |
commit | 190ba402d9a19e6cee7e3b893fc5df7c868d6b85 (patch) | |
tree | e09977ef05048be8a23999f109c9f8f04752461a /sdl-test | |
parent | 00c9327a1db50fab0b3a51a425a60e910cb5441d (diff) | |
download | 2010-netlemmings-190ba402d9a19e6cee7e3b893fc5df7c868d6b85.tar.gz 2010-netlemmings-190ba402d9a19e6cee7e3b893fc5df7c868d6b85.tar.bz2 2010-netlemmings-190ba402d9a19e6cee7e3b893fc5df7c868d6b85.zip |
bomber + acceleration
git-svn-id: file:///var/svn/2010-netlemmings/trunk@158 077b3477-7977-48bd-8428-443f22f7bfda
Diffstat (limited to 'sdl-test')
-rw-r--r-- | sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c | 448 | ||||
-rw-r--r-- | sdl-test/SDL_tuto/TestParserLemmingsLVL/parse_ini.yy | 1 |
2 files changed, 241 insertions, 208 deletions
diff --git a/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c b/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c index 31444ef..d13ef7c 100644 --- a/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c +++ b/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c @@ -798,14 +798,22 @@ int stateLemming(struct gameInit *gInit){ if(err==116){return 116;} if(err!=2){ k->data.pl->dir=err; + + k->data.pl->cptBrick=0; + k->data.pl->cptState=0; + k->ID=0; + break; } k->data.pl->cptState++; + // le temps de poser une brick + + // brick suivante ? if(k->data.pl->cptState >= lState){ // step created -> move up k->data.pl->cptState=0; k->data.pl->cptBrick++; - + if (k->data.pl->dir == 1) { k->x += 4;} // step forward else @@ -820,6 +828,11 @@ int stateLemming(struct gameInit *gInit){ fa=err; if(fa<8|| levitation > 0){ k->ID=0;//WALKER + + k->data.pl->cptBrick=0; + k->data.pl->cptState=0; + k->ID=0; + // a lemming can jump through the ceiling like in Mayhem2-Boiler Room if (levitation >= WALKER_OBSTACLE_HEIGHT) { // avoid getting stuck @@ -829,23 +842,28 @@ int stateLemming(struct gameInit *gInit){ k->data.pl->dir = (k->data.pl->dir==1) ? 0 : 1 ; break; } - if(k->data.pl->cptState >= STEPS_MAX){ + + + if(k->data.pl->cptBrick >= STEPS_MAX){ k->ID=12; //BUILDER_END break; } + + } else { + // on met le mask à un moment précis if (k->data.pl->cptState==9){ //-DEBUG-printf("insert mask\n"); - //err=putBrickPx(k->x,k->y,gInit->mapI.map.tabGif[11],gInit->mapI.map.cmap.bgColor,gInit->mapI.map.cmap.debrisColor); - //if(err!=0){return err;} - to.x=k->x; - to.y=k->y; - test_blit(gInit->mapI.map.tabGif[11],NULL,pTerrain,&to, 0); - test_blit(gInit->mapI.map.tabGif[11],NULL,pSpr_Lem,&to, 0); - test_blit(gInit->mapI.map.tabGif[11],NULL,pSprLemBack,&to, 0); - test_blit(gInit->mapI.map.tabGif[11],NULL,pStencil,&to, 0); - test_blit(gInit->mapI.map.tabGif[11],NULL,pStencilFixe,&to, 0); - + //err=putBrickPx(k->x,k->y,gInit->mapI.map.tabGif[11],gInit->mapI.map.cmap.bgColor,gInit->mapI.map.cmap.debrisColor); + //if(err!=0){return err;} + to.x=k->x; + to.y=k->y; + test_blit(gInit->mapI.map.tabGif[11],NULL,pTerrain,&to, 0); + test_blit(gInit->mapI.map.tabGif[11],NULL,pSpr_Lem,&to, 0); + test_blit(gInit->mapI.map.tabGif[11],NULL,pSprLemBack,&to, 0); + test_blit(gInit->mapI.map.tabGif[11],NULL,pStencil,&to, 0); + test_blit(gInit->mapI.map.tabGif[11],NULL,pStencilFixe,&to, 0); + if(k->data.pl->cptBrick >= STEPS_WARNING){ //-DEBUG-printf("Play Sound SND_TING\n"); //GameController.sound.play(GameController.SND_TING); @@ -917,7 +935,8 @@ int stateLemming(struct gameInit *gInit){ err=outOfLowerMap(k->y+fy); if(err==114){return 114;} if(err==1) {k->ID=17;} - if(k->data.pl->cptState==(gInit->mapI.lemmingDATA[10].state-2)){//16){ + if(k->data.pl->cptState==(0/*gInit->mapI.lemmingDATA[10].state*/)){//16){ + k->y-=8;//gInit->mapI.lemmingDATA[10].footY-gInit->mapI.lemmingDATA[0].footY; err=ereasePx(k->x,k->y,gInit->mapI.map.tabGif[10],gInit->mapI.map.cmap.bgColor); if(err!=0){return err;} //TODO @@ -1003,7 +1022,7 @@ int stateLemming(struct gameInit *gInit){ if((err=paint_manip(s,from,pStencilFixe,to,ccc_bgStencil,ccc_lemming,18,NULL))!=0){ return err; } - + return 0; } @@ -1021,10 +1040,19 @@ int stateLemming(struct gameInit *gInit){ to.w=x+s->w; to.h=y+s->h; - if((err=paint_manip(s,from,pTerrain,to,bgColor,ccc_lemming,17,pStencilFixe))!=0){ + if((err=paint_manip(s,from,pTerrain,to,bgColor,ccc_lemming,17,pStencil))!=0){ return err; } - if((err=paint_manip(s,from,pStencilFixe,to,ccc_bgStencil,ccc_lemming,18,NULL))!=0){ + + 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; } @@ -1714,6 +1742,9 @@ int stateLemming(struct gameInit *gInit){ gInit->o.lo=NULL; gInit->s.ls=NULL; gInit->l.ll=NULL; + + //boostFps + gInit->boostFps=0; // init button state for(i=0;i<NBR_CPT;++i){ @@ -1734,7 +1765,7 @@ int stateLemming(struct gameInit *gInit){ //miniMap gInit->mapI.miniMapLem=NULL; - + //curseur gInit->mapI.cross.oldX=0; gInit->mapI.cross.oldY=0; @@ -1787,7 +1818,7 @@ int stateLemming(struct gameInit *gInit){ //DEBUT TEST CREATION UN LEMMING // DEBUT DEBUG: LEMMING COLLISION - gInit->mapI.paraMap[1]=1; + //gInit->mapI.paraMap[1]=1; // FIN DEBUG: LEMMING COLLISION nbLem=gInit->mapI.paraMap[1]; @@ -1845,10 +1876,10 @@ int stateLemming(struct gameInit *gInit){ gInit->l.ll->data.pl->oldX=k->x; gInit->l.ll->data.pl->oldY=k->y; gInit->l.ll->data.pl->imgF=SDL_CreateRGBSurface(SDL_HWSURFACE|SDL_HWACCEL|/*SDL_ASYNCBLIT|*/SDL_RLEACCEL, DECALLEMX, DECALLEMY, - SCREEN_BPP,0,0,0,0); + SCREEN_BPP,0,0,0,0); SDL_SetColorKey(gInit->l.ll->data.pl->imgF, SDL_SRCCOLORKEY|SDL_RLEACCEL, 0); //SDL_SetColorKey(gInit->l.ll->data.pl->imgF, SDL_SRCCOLORKEY|SDL_RLEACCEL, gInit->mapI.map.cmap.bgColor); - + gInit->l.ll->next=NULL; if(gInit->mapI.nbrEntry==1){i=0;} @@ -1889,7 +1920,7 @@ int stateLemming(struct gameInit *gInit){ gInit->l.ll->data.pl->oldX=k->x; gInit->l.ll->data.pl->oldY=k->y; gInit->l.ll->data.pl->imgF=SDL_CreateRGBSurface(SDL_HWSURFACE|SDL_HWACCEL|/*SDL_ASYNCBLIT|*/SDL_RLEACCEL, DECALLEMX, DECALLEMY, - SCREEN_BPP,0,0,0,0); + SCREEN_BPP,0,0,0,0); SDL_SetColorKey(gInit->l.ll->data.pl->imgF, SDL_SRCCOLORKEY|SDL_RLEACCEL, 0); //SDL_SetColorKey(gInit->l.ll->data.pl->imgF, SDL_SRCCOLORKEY|SDL_RLEACCEL, gInit->mapI.map.cmap.bgColor); if(gInit->mapI.nbrEntry==1){i=0;} @@ -2375,7 +2406,7 @@ int stateLemming(struct gameInit *gInit){ 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)) { + 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; @@ -2396,7 +2427,7 @@ int stateLemming(struct gameInit *gInit){ 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)) { + 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; @@ -2508,27 +2539,27 @@ int stateLemming(struct gameInit *gInit){ offset.w=rStencil.w; offset.h=rStencil.h; /* - err=test_FillRect( pSpr_Lem, &offset, gInit->mapI.map.cmap.bgColor, 0); - if(err!=0){return err;} - err=test_blit(sf, &rStencil, pSpr_Lem, &offset,0); - if(err != 0){return err;}*/ + err=test_FillRect( pSpr_Lem, &offset, gInit->mapI.map.cmap.bgColor, 0); + if(err!=0){return err;} + err=test_blit(sf, &rStencil, pSpr_Lem, &offset,0); + if(err != 0){return err;}*/ err=test_FillRect( pSprLemBack, &offset,gInit->mapI.map.cmap.bgColor, 0); if(err!=0){return err;} err=test_blit(sf, &rStencil, pSprLemBack, &offset,0); if(err != 0){return err;} - + err=test_blit(pSprLemBack, &offset, pSpr_Lem, &offset,0); if(err != 0){return err;} - + } k=k->next; } - + }//for passage ///FIN TEST: SPR - // err=test_blit(pSprLemBack, NULL, pSpr_Lem, NULL,0); - // if(err != 0){return err;} + // err=test_blit(pSprLemBack, NULL, pSpr_Lem, NULL,0); + // if(err != 0){return err;} return 0; } @@ -2594,13 +2625,13 @@ int stateLemming(struct gameInit *gInit){ if(((Uint32 *)k->data.po->img->pixels)[xToW+yToH*sf->w+(hf*fit*sf->w)]==ccc_keyGif){ ((Uint32 *)k->data.po->img->pixels)[xToW+yToH*sf->w+(hf*fit*sf->w)]=err; // ou err } - + } } if(mode==0){ - if(((Uint32 *)k->data.po->img->pixels)[xToW+yToH*sf->w+(hf*fit*sf->w)]==ccc_keyGif){ - ((Uint32 *)k->data.po->img->pixels)[xToW+yToH*sf->w+(hf*fit*sf->w)]=err; // ou err - } + if(((Uint32 *)k->data.po->img->pixels)[xToW+yToH*sf->w+(hf*fit*sf->w)]==ccc_keyGif){ + ((Uint32 *)k->data.po->img->pixels)[xToW+yToH*sf->w+(hf*fit*sf->w)]=err; // ou err + } } } } @@ -2913,7 +2944,7 @@ int paint_lemming (struct gameInit *gInit, int cptFps){ default:break; } test_blit(sf, &objetAnim, pSpr_Lem, &offset,0); - + } k=k->next; @@ -3061,7 +3092,7 @@ int paint_cursor(SDL_Surface *dst1, SDL_Surface *src, int x, int y, int x0, stru int f=0; int err=0; struct listeSimplementChainee *k=NULL; - + /* Render! */ from.x = 0; from.h = src->h/8; @@ -3072,7 +3103,7 @@ int paint_cursor(SDL_Surface *dst1, SDL_Surface *src, int x, int y, int x0, stru to.y = y; if (y>LEVEL_HEIGHT){// cursor in pIterface to.y = y - LEVEL_HEIGHT ; - + //Save gInit->mapI.cross.oldX=to.x; gInit->mapI.cross.oldY=to.y; @@ -3090,8 +3121,8 @@ int paint_cursor(SDL_Surface *dst1, SDL_Surface *src, int x, int y, int x0, stru (x+15 >= k->x + 8)&&//)&& (y+15 <= k->y + 20)&& (y+15 > k->y )){//on the lemming - to.x=k->x; - to.y=k->y; + //to.x=k->x; + //to.y=k->y; from.y = 4 * (from.h); f=1; //begin giveSkill @@ -3123,7 +3154,7 @@ int paint_cursor(SDL_Surface *dst1, SDL_Surface *src, int x, int y, int x0, stru k=k->next; } //to.y -= 4; - + //Save before.x=gInit->mapI.cross.oldX=to.x; before.y=gInit->mapI.cross.oldY=to.y ; @@ -3138,36 +3169,36 @@ int paint_cursor(SDL_Surface *dst1, SDL_Surface *src, int x, int y, int x0, stru after.h=gInit->mapI.cross.sizeC; test_FillRect(gInit->mapI.cross.imgC, NULL, gInit->mapI.map.cmap.bgColor,0); test_blit(dst1, &before, gInit->mapI.cross.imgC, &after,0); - + test_blit(src, &from, dst1, &to,0); - + if((gInit->mapI.cross.sizeC >= 0)&&(gInit->mapI.cross.sizeC < from.h)){ to.x = (f==1)? k->x-x + x0 : x0; to.y = (f==1)? k->y /*- 4*/ - LEVEL_HEIGHT : y /*- 4*/ - LEVEL_HEIGHT ; - + // Save to.w=gInit->mapI.cross.imgC->w; to.h=gInit->mapI.cross.imgC->h - gInit->mapI.cross.sizeC; - + gInit->mapI.cross.oldXI=to.x; gInit->mapI.cross.oldYI=to.y; - + before.x=0; - + before.y=gInit->mapI.cross.sizeC; before.w=gInit->mapI.cross.imgC->w; before.h=to.h; //printf("gInit->mapI.cross.imgC->h %d -gInit->mapI.cross.sizeC %d = %d \n",gInit->mapI.cross.imgC->h,gInit->mapI.cross.sizeC,gInit->mapI.cross.imgC->h-gInit->mapI.cross.sizeC); - + gInit->mapI.cross.numScreen=2; - + test_FillRect(gInit->mapI.cross.imgC, &before, ccc_bgStencil,0); test_blit(pInterface, &to, gInit->mapI.cross.imgC, &before,0); //test_FillRect(gInit->mapI.cross.imgC, &before, ccc_red,0); - + test_blit(src, &from, pInterface, &to,0); - + } } gInit->cptGame[18]=0; @@ -3180,12 +3211,12 @@ int legende (struct gameInit *gInit){ int decalY = 11; int err=0; //char* msg=NULL; - + rStencil.x= 0; rStencil.y= INTER_BUTTON_Y -20 ; rStencil.w= 34*NBR_BUTTON_LEMMING; rStencil.h= 60; - + test_FillRect(pInterface, &rStencil, 0,0); rStencil.x= 400; @@ -3286,7 +3317,7 @@ int paint_interface (struct gameInit *gInit){ int err=0; SDL_Rect to,from; SDL_Surface *sf; - + test_FillRect(pInterface, NULL, 0,0); from.x = 0; @@ -3367,6 +3398,10 @@ int mouse_action (struct gameInit *gInit, int x, int y, int camX, int camY ){ l=l->next; } } + //SPEED ; BOOST FPS + if(numB==12){ + gInit->boostFps=((gInit->boostFps > FPS)? gInit->boostFps - 4*FPS : gInit->boostFps + 4*FPS ); + } for(i=0;i<NBR_BUTTON_LEMMING;++i){ if(i != numB){ @@ -3400,25 +3435,25 @@ int supprLem (struct gameInit *gInit, int cptFps){ { k=gInit->l.ll; if((k != NULL)&&(gInit->l.nbr == 1)){ - if((k->data.pl->cptState != 0 ) || (k->ID != 18)){ - // Restauration de la map - rect.x=k->data.pl->oldX; - rect.y=k->data.pl->oldY; - rect.w=k->data.pl->imgF->w; - rect.h=k->data.pl->imgF->h; - test_blit(k->data.pl->imgF,NULL, pSpr_Lem, &rect,0); - - // Sauvegarde de la map suivante - k->data.pl->oldX=k->x - DECALLE_X; - k->data.pl->oldY=k->y - DECALLE_Y; - rect.x=k->data.pl->oldX; - rect.y=k->data.pl->oldY; - //test_FillRect(pSpr_Lem, &rect, gInit->mapI.map.cmap.bgColor,0); - //test_blit(pTerrain,&rect, pSpr_Lem, &rect,0); - test_blit(pSprLemBack,&rect, k->data.pl->imgF, NULL,0); - //test_blit(pSpr_Lem,&rect, k->data.pl->imgF, NULL,0); - } - + if((k->data.pl->cptState != 0 ) || (k->ID != 18)){ + // Restauration de la map + rect.x=k->data.pl->oldX; + rect.y=k->data.pl->oldY; + rect.w=k->data.pl->imgF->w; + rect.h=k->data.pl->imgF->h; + test_blit(k->data.pl->imgF,NULL, pSpr_Lem, &rect,0); + + // Sauvegarde de la map suivante + k->data.pl->oldX=k->x - DECALLE_X; + k->data.pl->oldY=k->y - DECALLE_Y; + rect.x=k->data.pl->oldX; + rect.y=k->data.pl->oldY; + //test_FillRect(pSpr_Lem, &rect, gInit->mapI.map.cmap.bgColor,0); + //test_blit(pTerrain,&rect, pSpr_Lem, &rect,0); + test_blit(pSprLemBack,&rect, k->data.pl->imgF, NULL,0); + //test_blit(pSpr_Lem,&rect, k->data.pl->imgF, NULL,0); + } + if(k->ID == 17){++gInit->l.nbrDied; --gInit->l.nbr;} if(k->ID == 19){++gInit->l.nbrSafe; --gInit->l.nbr;} if((k->ID == 17)||(k->ID == 19)) {k=NULL;} @@ -3449,101 +3484,101 @@ int supprLem (struct gameInit *gInit, int cptFps){ } //-DEBUG-printf("nbrInput = %d\nnbrInGame = %d\nnbrDied = %d\nnbrSafe = %d\n",gInit->l.nbrInput,gInit->l.nbr,gInit->l.nbrDied,gInit->l.nbrSafe); } else { - k=gInit->l.ll; - while ( k !=NULL ) { - if((k->data.pl->cptState != 0 ) || (k->ID != 18)){ - // Restauration de la map - rect.x=k->data.pl->oldX; - rect.y=k->data.pl->oldY; - rect.w=k->data.pl->imgF->w; - rect.h=k->data.pl->imgF->h; - test_blit(k->data.pl->imgF,NULL, pSpr_Lem, &rect,0); - - // Sauvegarde de la map suivante - k->data.pl->oldX=k->x - DECALLE_X; - k->data.pl->oldY=k->y - DECALLE_Y; - rect.x=k->data.pl->oldX; - rect.y=k->data.pl->oldY; - //test_FillRect(pSpr_Lem, &rect, gInit->mapI.map.cmap.bgColor,0); - //test_blit(pTerrain,&rect, pSpr_Lem, &rect,0); - test_blit(pSprLemBack,&rect, k->data.pl->imgF, NULL,0); - //test_blit(pSpr_Lem,&rect, k->data.pl->imgF, NULL,0); + k=gInit->l.ll; + while ( k !=NULL ) { + if((k->data.pl->cptState != 0 ) || (k->ID != 18)){ + // Restauration de la map + rect.x=k->data.pl->oldX; + rect.y=k->data.pl->oldY; + rect.w=k->data.pl->imgF->w; + rect.h=k->data.pl->imgF->h; + test_blit(k->data.pl->imgF,NULL, pSpr_Lem, &rect,0); + + // Sauvegarde de la map suivante + k->data.pl->oldX=k->x - DECALLE_X; + k->data.pl->oldY=k->y - DECALLE_Y; + rect.x=k->data.pl->oldX; + rect.y=k->data.pl->oldY; + //test_FillRect(pSpr_Lem, &rect, gInit->mapI.map.cmap.bgColor,0); + //test_blit(pTerrain,&rect, pSpr_Lem, &rect,0); + test_blit(pSprLemBack,&rect, k->data.pl->imgF, NULL,0); + //test_blit(pSpr_Lem,&rect, k->data.pl->imgF, NULL,0); + } + k=k->next; } - k=k->next; - } - + } return 0; } int restorCursor(struct gameInit *gInit, int choix){ SDL_Rect to,from; - - if(choix==0){ - switch(gInit->mapI.cross.numSwitch){ - case 0 : break; - case 2 : gInit->mapI.cross.numSwitch=2;break; - case 1 : gInit->mapI.cross.numSwitch=5;break; - case 3 : gInit->mapI.cross.numSwitch=5;break; - default: gInit->mapI.cross.numSwitch=0;break; - }} - if(choix==1) { - switch(gInit->mapI.cross.numSwitch){ - case 1 : break; - case 3 : gInit->mapI.cross.numSwitch=3;break; - case 0 : gInit->mapI.cross.numSwitch=6;break; - case 2 : gInit->mapI.cross.numSwitch=6;break; - default: gInit->mapI.cross.numSwitch=1;break; - } - + + if(choix==0){ + switch(gInit->mapI.cross.numSwitch){ + case 0 : break; + case 2 : gInit->mapI.cross.numSwitch=2;break; + case 1 : gInit->mapI.cross.numSwitch=5;break; + case 3 : gInit->mapI.cross.numSwitch=5;break; + default: gInit->mapI.cross.numSwitch=0;break; + }} + if(choix==1) { + switch(gInit->mapI.cross.numSwitch){ + case 1 : break; + case 3 : gInit->mapI.cross.numSwitch=3;break; + case 0 : gInit->mapI.cross.numSwitch=6;break; + case 2 : gInit->mapI.cross.numSwitch=6;break; + default: gInit->mapI.cross.numSwitch=1;break; } - //Restauration cursor - if(gInit->mapI.cross.numScreen==0){ - to.x=gInit->mapI.cross.oldX; - to.y=gInit->mapI.cross.oldY; - test_blit(gInit->mapI.cross.imgC, NULL, pInterface, &to,0); + } + + //Restauration cursor + if(gInit->mapI.cross.numScreen==0){ + to.x=gInit->mapI.cross.oldX; + to.y=gInit->mapI.cross.oldY; + test_blit(gInit->mapI.cross.imgC, NULL, pInterface, &to,0); + } + + if(gInit->mapI.cross.numScreen==1){ + to.x=gInit->mapI.cross.oldX; + to.y=gInit->mapI.cross.oldY; + if((gInit->mapI.cross.numSwitch==0)||(gInit->mapI.cross.numSwitch==2)||(gInit->mapI.cross.numSwitch==6)){ + test_blit(gInit->mapI.cross.imgC, NULL, pSpr_Lem, &to,0); } - - if(gInit->mapI.cross.numScreen==1){ - to.x=gInit->mapI.cross.oldX; - to.y=gInit->mapI.cross.oldY; - if((gInit->mapI.cross.numSwitch==0)||(gInit->mapI.cross.numSwitch==2)||(gInit->mapI.cross.numSwitch==6)){ - test_blit(gInit->mapI.cross.imgC, NULL, pSpr_Lem, &to,0); - } - if((gInit->mapI.cross.numSwitch==1)||(gInit->mapI.cross.numSwitch==3)||(gInit->mapI.cross.numSwitch==5)){ - test_blit(gInit->mapI.cross.imgC, NULL, pStencil, &to,0); - } - + if((gInit->mapI.cross.numSwitch==1)||(gInit->mapI.cross.numSwitch==3)||(gInit->mapI.cross.numSwitch==5)){ + test_blit(gInit->mapI.cross.imgC, NULL, pStencil, &to,0); } - - if(gInit->mapI.cross.numScreen==2){ - from.x=0; - //--- - from.y=0; - to.x=gInit->mapI.cross.oldX; - to.y=gInit->mapI.cross.oldY; - to.w=from.w=gInit->mapI.cross.imgC->w; - to.h=from.h=gInit->mapI.cross.sizeC; - if((gInit->mapI.cross.numSwitch==0)||(gInit->mapI.cross.numSwitch==2)||(gInit->mapI.cross.numSwitch==6)){ - test_blit(gInit->mapI.cross.imgC, &from, pSpr_Lem, &to,0); - } - if((gInit->mapI.cross.numSwitch==1)||(gInit->mapI.cross.numSwitch==3)||(gInit->mapI.cross.numSwitch==5)){ - test_blit(gInit->mapI.cross.imgC, &from, pStencil, &to,0); - } - - to.x=gInit->mapI.cross.oldXI; - to.y=gInit->mapI.cross.oldYI;// - LEVEL_HEIGHT; - - from.y=gInit->mapI.cross.sizeC; - - to.w=from.w=gInit->mapI.cross.imgC->w; - to.h=from.h=1000;//gInit->mapI.cross.imgC->h-gInit->mapI.cross.sizeC; - - test_blit(gInit->mapI.cross.imgC, /*&from*/NULL,pInterface, &to,0); - } - -return 0; + + } + + if(gInit->mapI.cross.numScreen==2){ + from.x=0; + //--- + from.y=0; + to.x=gInit->mapI.cross.oldX; + to.y=gInit->mapI.cross.oldY; + to.w=from.w=gInit->mapI.cross.imgC->w; + to.h=from.h=gInit->mapI.cross.sizeC; + if((gInit->mapI.cross.numSwitch==0)||(gInit->mapI.cross.numSwitch==2)||(gInit->mapI.cross.numSwitch==6)){ + test_blit(gInit->mapI.cross.imgC, &from, pSpr_Lem, &to,0); + } + if((gInit->mapI.cross.numSwitch==1)||(gInit->mapI.cross.numSwitch==3)||(gInit->mapI.cross.numSwitch==5)){ + test_blit(gInit->mapI.cross.imgC, &from, pStencil, &to,0); + } + + to.x=gInit->mapI.cross.oldXI; + to.y=gInit->mapI.cross.oldYI;// - LEVEL_HEIGHT; + + from.y=gInit->mapI.cross.sizeC; + + to.w=from.w=gInit->mapI.cross.imgC->w; + to.h=from.h=1000;//gInit->mapI.cross.imgC->h-gInit->mapI.cross.sizeC; + + test_blit(gInit->mapI.cross.imgC, /*&from*/NULL,pInterface, &to,0); + } + + return 0; } @@ -3560,7 +3595,6 @@ int lancement (){ 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; @@ -3608,10 +3642,10 @@ int lancement (){ // CREATION OF SOME LEMMING err=creationLemming(&gInit); if(err!=0){return err;} - - + + SDL_WM_SetCaption( gInit.mapI.name , NULL ); - + gInit.mapI.cross.imgC=SDL_CreateRGBSurface(SDL_HWSURFACE|SDL_HWACCEL|/*SDL_ASYNCBLIT|*/SDL_RLEACCEL, gInit.mapI.map.tabGif[3]->w , gInit.mapI.map.tabGif[3]->h/8, SCREEN_BPP,0,0,0,0); //SDL_SetColorKey(pTerrain, SDL_SRCCOLORKEY|SDL_RLEACCEL, gInit.mapI.map.cmap.bgColor); @@ -3650,7 +3684,7 @@ int lancement (){ 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;} @@ -3663,16 +3697,16 @@ int lancement (){ test_blit(pStencil, NULL, pStencilFixe, NULL,0); //<-- //Tant que l'utilisateur n'a pas quitter - test_FillRect( pSpr_Lem, NULL, gInit.mapI.map.cmap.bgColor,0); - test_FillRect( pSprLemBack, NULL, gInit.mapI.map.cmap.bgColor,0); - - test_blit(pTerrain, NULL, pSpr_Lem, NULL,0); - test_blit(pTerrain, NULL, pSprLemBack, NULL,0); - - test_FillRect( screen, &inter, ccc_black,0); - test_FillRect( pInterface, NULL , ccc_black,0); - test_FillRect( pStencil, NULL, ccc_bgStencil,0); - test_blit(pStencilFixe, NULL, pStencil, NULL,0); + test_FillRect( pSpr_Lem, NULL, gInit.mapI.map.cmap.bgColor,0); + test_FillRect( pSprLemBack, NULL, gInit.mapI.map.cmap.bgColor,0); + + test_blit(pTerrain, NULL, pSpr_Lem, NULL,0); + test_blit(pTerrain, NULL, pSprLemBack, NULL,0); + + test_FillRect( screen, &inter, ccc_black,0); + test_FillRect( pInterface, NULL , ccc_black,0); + test_FillRect( pStencil, NULL, ccc_bgStencil,0); + test_blit(pStencilFixe, NULL, pStencil, NULL,0); while( quit == 0 ) { @@ -3683,10 +3717,10 @@ int lancement (){ while( SDL_PollEvent( &event ) ) { switch(event.key.keysym.sym){ - case SDLK_HOME : decalFps = 0; break; - case SDLK_END : decalFps = FPS-11; break; - case SDLK_PAGEUP : if(decalFps>0){decalFps -=1;}break; - case SDLK_PAGEDOWN : if(decalFps<(FPS-1)){decalFps +=1;}break; + case SDLK_HOME : gInit.boostFps = 0; break; + case SDLK_END : gInit.boostFps = FPS-11; break; + case SDLK_PAGEUP : if(gInit.boostFps>0){gInit.boostFps -=1;}break; + case SDLK_PAGEDOWN : if(gInit.boostFps<(FPS-1)){gInit.boostFps +=1;}break; case SDLK_w : paint_stencil= (paint_stencil==0)? 1 : ((paint_stencil==1)? 2 : ((paint_stencil==2)? 3 : 0)) ;permission=0;break; case SDLK_x : switchMiniMapMode= (switchMiniMapMode==0)? 1 : ((switchMiniMapMode==1)? 2 : ((switchMiniMapMode==2)? 3 : 0)) ;permission=0;break; case SDLK_p :{ @@ -3739,27 +3773,27 @@ int lancement (){ //test_FillRect( pInterface, NULL , ccc_black,0); //test_FillRect( pStencil, NULL, ccc_bgStencil,0); //test_blit(pStencilFixe, NULL, pStencil, NULL,0); - + //restoration cursor err=restorCursor(&gInit,paint_stencil); if (err!=0){return err;} - + // SPR => pSpr_Lem err=paint_objet (&gInit,cptFps); if(err!=0){return err;} // SUPPR LEM => gInit - err=supprLem(&gInit,cptFps); - if(err!=0){return err;} + err=supprLem(&gInit,cptFps); + if(err!=0){return err;} // LEM => pSpr_Lem //if(paint_stencil==0){ - + err=paint_lemming (&gInit,cptFps); if(err!=0){return err;} //} - + // INTERFACE => screen if((paint_stencil==0)&&(permission==0)){ @@ -3784,7 +3818,7 @@ int lancement (){ err=miniMap (pStencil,mouseX+camera.x,mouseY+camera.y,zoomX,zoomY); if( err != 0){ return err;} }} else { - + if((permission==0)&&((paint_stencil==0)||(paint_stencil==1))){ test_blit(gInit.mapI.miniMapLem,NULL , pInterface, &miniMapR,0); } @@ -3792,30 +3826,30 @@ int lancement (){ // CURSOR => pSpr_Lem, screen if(paint_stencil==0){ - + err=paint_cursor (pSpr_Lem, gInit.mapI.map.tabGif[3], mouseX+camera.x, mouseY+camera.y, mouseX, &gInit); if(err!=0){return err;} - + if(gInit.mapI.cross.numSwitch==0){gInit.mapI.cross.numSwitch=2;} - + } else { /*err=findTerrain(&gInit,mouseX+camera.x, mouseY+camera.y, mouseX); - if(err!=0){return err;}*/ - + if(err!=0){return err;}*/ + err=paint_cursor (pStencil, gInit.mapI.map.tabGif[3], mouseX+camera.x, mouseY+camera.y, mouseX, &gInit); if(err!=0){return err;} - + if(gInit.mapI.cross.numSwitch==1){gInit.mapI.cross.numSwitch=3;} - + //-DEBUG-printf("x=%d y=%d\n",mouseX+camera.x,mouseY+camera.y); } if(paint_stencil==0){ - test_blit(pSpr_Lem, &camera, screen, NULL,0); + test_blit(pSpr_Lem, &camera, screen, NULL,0); } else { - test_blit(pStencil, &camera, screen, NULL,0); + test_blit(pStencil, &camera, screen, NULL,0); } - - + + /* FPS counter */ //-DEBUG-printf("(tick %ld > fps_start %d +500)\n",tick,fps_start); // refresh fps all 500 ms @@ -3828,11 +3862,11 @@ int lancement (){ ++fps_count; - if (cptFps == 99999) { + /* if (cptFps == 99999) { //if(SDL_GetTicks()==240000){ - //decalFps = 99; + printf("STOP ! cptFps == 99999 \n"); quit=1; - } + } */ // limte fps temps = SDL_GetTicks(); @@ -3851,16 +3885,16 @@ int lancement (){ err=print_num(pInterface, gInit.mapI.map.tabGif[1], pInterface->w-87, pInterface->h-10, fps); if(err!=0){return err;} - err=print_num(pInterface, gInit.mapI.map.tabGif[1], pInterface->w-37, pInterface->h-10, FPS); + err=print_num(pInterface, gInit.mapI.map.tabGif[1], pInterface->w-37, pInterface->h-10, FPS+gInit.boostFps); if(err!=0){return err;} test_blit(pInterface, NULL , screen, &inter,0); - if(FPS<=decalFps){//-DEBUG-printf("BUG: FPS < 0 : (FPS %d - decalFps %d) < 0",FPS,decalFps); + if(FPS+gInit.boostFps <= 0){//-DEBUG-printf("BUG: FPS %d +gInit.boostFps %d <= 0",FPS,gInit.boostFps); return(42); } else { - while((FPS>decalFps)&&(((float)fps_count * 1000.0 / (SDL_GetTicks()-fps_start)) > FPS-decalFps) ){ - if((FPS-decalFps)<=120){// useless ? + while(((float)fps_count * 1000.0 / (SDL_GetTicks()-fps_start) > FPS+gInit.boostFps) ){ + if((FPS+gInit.boostFps)<=120){// useless ? SDL_Delay(3); } }} @@ -3876,12 +3910,10 @@ int lancement (){ //SDL_Delay(1); - if(FPS<=decalFps){//-DEBUG-printf("BUG: FPS < 0 : (FPS %d - decalFps %d) < 0",FPS,decalFps); - return(43); - } else { - //-DEBUG-temps = SDL_GetTicks(); - //-DEBUG-printf("cptFps = %d, time: %ld:%ld:%ld \n",cptFps,temps/(1000*3600),(temps/(1000*60))%60,(temps/1000)%60); - } + + //-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++; //quit = 1; diff --git a/sdl-test/SDL_tuto/TestParserLemmingsLVL/parse_ini.yy b/sdl-test/SDL_tuto/TestParserLemmingsLVL/parse_ini.yy index 714fa8f..d40a418 100644 --- a/sdl-test/SDL_tuto/TestParserLemmingsLVL/parse_ini.yy +++ b/sdl-test/SDL_tuto/TestParserLemmingsLVL/parse_ini.yy @@ -472,6 +472,7 @@ struct objet o; // all DATA of objet on this map; struct steel s; // all DATA of steel on this map; struct lemming l; // all DATA of lemming on this map; + int boostFps; // grow up FPS *5; default=0; // 0-13 : BUTTON_LEMMING state button 0: off; 1: on; // 14 : CURSOR STATE // 15 : FREE CPT: for all need it ...; default=0; |