diff options
author | Damien Appert <dappert> | 2010-11-17 14:23:39 +0000 |
---|---|---|
committer | Damien Appert <dappert> | 2010-11-17 14:23:39 +0000 |
commit | 61ff7a1b6736109ea1b555f74455a28f38d58cb3 (patch) | |
tree | aed92fc000f9f416085966184a1327f839e8aa81 /sdl-test | |
parent | 3b90bf04c8fb6935fa6be7d907d69ea0fddc8218 (diff) | |
download | 2010-netlemmings-61ff7a1b6736109ea1b555f74455a28f38d58cb3.tar.gz 2010-netlemmings-61ff7a1b6736109ea1b555f74455a28f38d58cb3.tar.bz2 2010-netlemmings-61ff7a1b6736109ea1b555f74455a28f38d58cb3.zip |
lemming bomber chiffre ok mais pas son explosion
git-svn-id: file:///var/svn/2010-netlemmings/trunk@153 077b3477-7977-48bd-8428-443f22f7bfda
Diffstat (limited to 'sdl-test')
-rw-r--r-- | sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c | 221 | ||||
-rw-r--r-- | sdl-test/SDL_tuto/TestParserLemmingsLVL/parse_ini.yy | 4 |
2 files changed, 113 insertions, 112 deletions
diff --git a/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c b/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c index 5cc9a46..b4563b7 100644 --- a/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c +++ b/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c @@ -991,7 +991,7 @@ 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,pStencilixe))!=0){ return err; } if((err=paint_manip(s,from,pStencilFixe,to,ccc_bgStencil,ccc_lemming,18,NULL))!=0){ @@ -1814,7 +1814,7 @@ int stateLemming(struct gameInit *gInit){ gInit->l.ll->data.pl->cptBrick=0; 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, 32, 20, + gInit->l.ll->data.pl->imgF=SDL_CreateRGBSurface(SDL_HWSURFACE|SDL_HWACCEL|/*SDL_ASYNCBLIT|*/SDL_RLEACCEL, 32, 20+DECALLEM, 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); @@ -1858,7 +1858,7 @@ int stateLemming(struct gameInit *gInit){ gInit->l.ll->data.pl->cptBrick=0; 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, 32, 20, + gInit->l.ll->data.pl->imgF=SDL_CreateRGBSurface(SDL_HWSURFACE|SDL_HWACCEL|/*SDL_ASYNCBLIT|*/SDL_RLEACCEL, 32, 20+DECALLEM, 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); @@ -2051,7 +2051,7 @@ int stateLemming(struct gameInit *gInit){ //int cpt=0; - gInit->mapI.miniMapLem=SDL_CreateRGBSurface(SDL_HWSURFACE|SDL_HWACCEL|SDL_ASYNCBLIT|SDL_RLEACCEL, + gInit->mapI.miniMapLem=SDL_CreateRGBSurface(SDL_HWSURFACE|SDL_HWACCEL|/*SDL_ASYNCBLIT|*/SDL_RLEACCEL, MINIMAPLEM_MX, MINIMAPLEM_MY, SCREEN_BPP,0,0,0,0); @@ -2289,6 +2289,7 @@ int stateLemming(struct gameInit *gInit){ SDL_LockSurface(spr); SDL_LockSurface(t); + if(stencil!=NULL) SDL_LockSurface(stencil); memcpy(temp_pixels,spr->pixels,size); // NO OVERWRITE @@ -2338,7 +2339,7 @@ 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)]; - ccc_temp3=((Uint32 *)stencil->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)) { ((Uint32 *)spr->pixels)[(from.y+j)*spr->w+from.x+i]=ccc_t;//spr->format->colorkey; @@ -2391,6 +2392,7 @@ int stateLemming(struct gameInit *gInit){ } + if(stencil!=NULL) SDL_UnlockSurface(stencil); SDL_UnlockSurface(t); SDL_UnlockSurface(spr); test_blit(spr,&from, t,&to,0); @@ -3025,52 +3027,6 @@ int paint_cursor(SDL_Surface *dst1, SDL_Surface *src, int x, int y, int x0, stru int err=0; struct listeSimplementChainee *k=NULL; - //Restauration - - 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.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); - } - /* Render! */ from.x = 0; from.h = src->h/8; @@ -3188,7 +3144,14 @@ int legende (struct gameInit *gInit){ SDL_Rect rStencil; int decalY = 11; int err=0; - //char* msg=NULL; + //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; rStencil.y= 1; @@ -3288,6 +3251,8 @@ 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; to.y = INTER_BUTTON_Y; @@ -3410,7 +3375,7 @@ int supprLem (struct gameInit *gInit, int cptFps){ // Sauvegarde de la map suivante k->data.pl->oldX=k->x; - k->data.pl->oldY=k->y; + k->data.pl->oldY=k->y-DECALLEM; rect.x=k->data.pl->oldX; rect.y=k->data.pl->oldY; //test_FillRect(pSpr_Lem, &rect, gInit->mapI.map.cmap.bgColor,0); @@ -3461,7 +3426,7 @@ int supprLem (struct gameInit *gInit, int cptFps){ // Sauvegarde de la map suivante k->data.pl->oldX=k->x; - k->data.pl->oldY=k->y; + k->data.pl->oldY=k->y-DECALLEM; rect.x=k->data.pl->oldX; rect.y=k->data.pl->oldY; //test_FillRect(pSpr_Lem, &rect, gInit->mapI.map.cmap.bgColor,0); @@ -3476,6 +3441,76 @@ int supprLem (struct gameInit *gInit, int cptFps){ 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; + } + + } + + //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.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; +} + // Par défaut, c'est l'analyse LEXICALE qui est lancée ! int lancement (){ @@ -3494,6 +3529,7 @@ int lancement (){ float zoomX=0.10; float zoomY=0.10; int switchMiniMapMode=0; + int permission=0; //La structure d'evenement SDL_Event event; event.type=0; @@ -3616,8 +3652,8 @@ int lancement (){ 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_w : paint_stencil= (paint_stencil==0)? 1 : ((paint_stencil==1)? 2 : ((paint_stencil==2)? 3 : 0)) ;break; - case SDLK_x : switchMiniMapMode= (switchMiniMapMode==0)? 1 : ((switchMiniMapMode==1)? 2 : ((switchMiniMapMode==2)? 3 : 0)) ;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 :{ zoomX=((zoomX >= 1. )? zoomX + 1. : zoomX + 0.1 ); zoomY=((zoomY >= 1. )? zoomY + 1. : zoomY + 0.1 ); @@ -3640,7 +3676,7 @@ int lancement (){ switch (event.type) { case SDL_MOUSEMOTION: { mouseX = event.motion.x; mouseY = event.motion.y;break; } - case SDL_MOUSEBUTTONDOWN: { err=mouse_action (&gInit, mouseX, mouseY,camera.x,camera.y ); + case SDL_MOUSEBUTTONDOWN: { permission=0;err=mouse_action (&gInit, mouseX, mouseY,camera.x,camera.y ); if(err!=0){return err;} break;} case SDL_QUIT : { @@ -3669,6 +3705,10 @@ int lancement (){ //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); @@ -3681,40 +3721,17 @@ int lancement (){ // LEM => pSpr_Lem //if(paint_stencil==0){ - - /* k=gInit.l.ll; - while(k!=NULL){ - 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); - k=k->next; - } - */ - err=paint_lemming (&gInit,cptFps); if(err!=0){return err;} //} - /* k=gInit.l.ll; - while(k!=NULL){ - rect.x=k->data.pl->oldX; - rect.y=k->data.pl->oldY; - k->data.pl->oldX=k->x; - k->data.pl->oldY=k->y; - rect.w=k->data.pl->imgF->w; - rect.h=k->data.pl->imgF->h; - test_blit(pSpr_Lem,&rect, k->data.pl->imgF, NULL,0); - k=k->next; - }*/ // INTERFACE => screen - if(paint_stencil==0){ + if((paint_stencil==0)&&(permission==0)){ err=paint_interface (&gInit); if(err!=0){return err;} } - if(paint_stencil==2){ + if(paint_stencil==1){ //testAlpha(screen, gInit.mapI.map.tabGif[9],gInit.mapI.map.tabGif[1],2,330); err=legende (&gInit); if(err!=0){return err;} @@ -3729,51 +3746,28 @@ int lancement (){ err=miniMap (pSpr_Lem,mouseX+camera.x,mouseY+camera.y,zoomX,zoomY);//0.10,0.10); 5.,5.); if( err != 0){ return err;} } - if(paint_stencil==2){ + if(paint_stencil==1){ err=miniMap (pStencil,mouseX+camera.x,mouseY+camera.y,zoomX,zoomY); if( err != 0){ return err;} }} else { - if(paint_stencil==0){ + + if((permission==0)&&((paint_stencil==0)||(paint_stencil==1))){ test_blit(gInit.mapI.miniMapLem,NULL , pInterface, &miniMapR,0); } - if(paint_stencil==2){ - test_blit(gInit.mapI.miniMapLem,NULL , pInterface, &miniMapR,0); - } - } // CURSOR => pSpr_Lem, screen if(paint_stencil==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(gInit.mapI.cross.numSwitch==0){gInit.mapI.cross.numSwitch=2;}else{gInit.mapI.cross.numSwitch=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;} } - if(paint_stencil==2) { - err=findTerrain(&gInit,mouseX+camera.x, mouseY+camera.y, mouseX); - if(err!=0){return err;} - - 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(gInit.mapI.cross.numSwitch==1){gInit.mapI.cross.numSwitch=3;}else{gInit.mapI.cross.numSwitch=1;} + if(paint_stencil==1) { + /*err=findTerrain(&gInit,mouseX+camera.x, mouseY+camera.y, mouseX); + 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;} @@ -3785,7 +3779,7 @@ int lancement (){ if(paint_stencil==0){ test_blit(pSpr_Lem, &camera, screen, NULL,0); } - if(paint_stencil==2){ + if(paint_stencil==1){ test_blit(pStencil, &camera, screen, NULL,0); } @@ -3839,6 +3833,9 @@ int lancement (){ } }} + if(permission==0){ + permission=1; + } //Mise à jour de l'écran if( SDL_Flip( screen ) == -1 ) { diff --git a/sdl-test/SDL_tuto/TestParserLemmingsLVL/parse_ini.yy b/sdl-test/SDL_tuto/TestParserLemmingsLVL/parse_ini.yy index 88759db..e327058 100644 --- a/sdl-test/SDL_tuto/TestParserLemmingsLVL/parse_ini.yy +++ b/sdl-test/SDL_tuto/TestParserLemmingsLVL/parse_ini.yy @@ -16,6 +16,8 @@ /** redraw animated level obejcts every 3rd frame (about 100ms) */ #define ANIM_STEP_FPS 3 +#define DECALLEM 15 + // the original formula is: release lemming every 4+(99-speed)/2 time steps // where one step is 60ms (3s/50) or 66ms (4s/60). // Lemmini runs at 30ms/33ms, so the term has to be multiplied by 2 @@ -581,6 +583,8 @@ int miniMap (SDL_Surface *s, int x0, int y0, float coefX, float coefY); int miniMapLemming (struct gameInit *gInit); + + int restorCursor(struct gameInit *gInit, int choix); int paint_stencil=0; |