diff options
Diffstat (limited to 'sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c')
-rw-r--r-- | sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c | 107 |
1 files changed, 72 insertions, 35 deletions
diff --git a/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c b/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c index df0e46d..88695d3 100644 --- a/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c +++ b/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c @@ -389,7 +389,7 @@ int stateLemming(struct gameInit *gInit){ struct listeSimplementChainee *k; struct listeSimplementChainee *o; - SDL_Rect from,to; + SDL_Rect to; SDL_Surface *sfT; int boom=0; int flip=0; @@ -1612,8 +1612,9 @@ int stateLemming(struct gameInit *gInit){ 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; + int i,j,stepScreenX,stepScreenY,sizeMiniMapPixel_X,sizeMiniMapPixel_Y; + int w0,h0,x,y,cpt=0; + SDL_Rect rect,from; Uint32 err; //int cpt=0; @@ -1674,6 +1675,15 @@ int stateLemming(struct gameInit *gInit){ if(coefY>1.) {h0=LEVEL_HEIGHT-y0;} else {y0=LEVEL_HEIGHT-h0;} } + /* + if(h0/2+y0 != MINIMAP_Y0+MINIMAP_MY/2){ + y0 += (MINIMAP_Y0+MINIMAP_MY/2)-(h0/2+y0); + } + + if(w0/2+x0 != MINIMAP_X0+MINIMAP_MX/2){ + x0 += (MINIMAP_X0+MINIMAP_MX/2)-(w0/2+x0); + }*/ + if((w0 + x0 >LEVEL_WIDTH)||(h0 + y0 > LEVEL_HEIGHT)){return 0;} @@ -1694,27 +1704,51 @@ int stateLemming(struct gameInit *gInit){ //SDL_LockSurface(s); - for(j=0;j<h0;j+=stepScreenY){ - if((y0+j)<0){continue;} - rect.y=MINIMAP_Y0+(j/stepScreenY)*sizeMiniMapPixel_Y; - if(rect.y>MINIMAP_Y0+MINIMAP_MY){break;} - if(rect.h+rect.y>MINIMAP_Y0+MINIMAP_MY){break;} - - for(i=0;i<w0;i+=stepScreenX){ - //cpt++; - - if((x0+i)<0){continue;} - rect.x=MINIMAP_X0+(i/stepScreenX)*sizeMiniMapPixel_X; - if(rect.x>MINIMAP_X0+MINIMAP_MX){break;} - if(rect.w+rect.x>MINIMAP_X0+MINIMAP_MX){break;} - - err=get_pixel32(x0+i,y0+j,s); - if(err==ccc_error){return 123;} + if((coefX==1.) && (coefX==coefY)){ + + from.x=x0; + from.y=y0; + from.w=MINIMAP_MX; + from.h=MINIMAP_MY; + + rect.x=MINIMAP_X0; + rect.y=MINIMAP_Y0; + rect.w=MINIMAP_MX; + rect.h=MINIMAP_MY; + + test_blit(s,&from,pInterface,&rect,0); + + } else { + for(j=0;j<h0;j+=stepScreenY){ + if((y0+j)<0){continue;} + rect.y=MINIMAP_Y0+(j/stepScreenY)*sizeMiniMapPixel_Y; + if(rect.y>MINIMAP_Y0+MINIMAP_MY){break;} + if(rect.h+rect.y>MINIMAP_Y0+MINIMAP_MY){break;} + cpt++; + for(i=0;i<w0;i+=stepScreenX){ + //cpt++; + + if((x0+i)<0){continue;} + rect.x=MINIMAP_X0+(i/stepScreenX)*sizeMiniMapPixel_X; + if(rect.x>MINIMAP_X0+MINIMAP_MX){break;} + if(rect.w+rect.x>MINIMAP_X0+MINIMAP_MX){break;} + + err=get_pixel32(x0+i,y0+j,s); + if(err==ccc_error){return 123;} - test_FillRect(pInterface, &rect, err,0); + test_FillRect(pInterface, &rect, err,0); - } + } + } + if(coefY<1.){ + rect.x=MINIMAP_X0; + rect.y=MINIMAP_Y0; + rect.w=MINIMAP_MX; + rect.h=MINIMAP_MY - cpt*sizeMiniMapPixel_Y ; + test_FillRect(pInterface, &rect, 0,0); + } } + //SDL_UnlockSurface(s); //printf("cpt = %d\n",cpt); @@ -2900,9 +2934,11 @@ int lancement (){ int err=0; //Ce qui va nous permettre de quitter int quit = 0; + int b=0; SDL_Rect camera,inter,miniMapR; int mouseX,mouseY=0; - long tick,temps=0; + long tick; + //long temps=0; float fps = 0.0; int fps_count = 0; int fps_start = 0; @@ -3026,37 +3062,38 @@ int lancement (){ //Tant qu'il y a un événement while( SDL_PollEvent( &event ) ) - { + { + b=(b==0)?1:0; switch(event.key.keysym.sym){ - case SDLK_HOME : gInit.tps.boostFps = 500-FPS; break; - case SDLK_END : gInit.tps.boostFps = -(FPS-11); break; - case SDLK_PAGEUP : if(gInit.tps.boostFps<(500-FPS)){gInit.tps.boostFps +=1;}break; - case SDLK_PAGEDOWN : if(gInit.tps.boostFps>(-FPS+1)){gInit.tps.boostFps -=1;}break; + case SDLK_HOME : if(b){gInit.tps.boostFps = 500-FPS;} break; + case SDLK_END : if(b){gInit.tps.boostFps = -(FPS-11);} break; + case SDLK_PAGEUP : if(b){if(gInit.tps.boostFps<(500-FPS)){gInit.tps.boostFps +=1;}}break; + case SDLK_PAGEDOWN : if(b){if(gInit.tps.boostFps>(-FPS+1)){gInit.tps.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 :{ + case SDLK_p :if(b){ 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 :{ + break; + case SDLK_m : if(b){ 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; + if(zoomX <= 0.1) {zoomX=0.1;} + if(zoomY <= 0.1) {zoomY=0.1;} } + break; case SDLK_ESCAPE : quit = 1; break; default:break; } // SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE); switch (event.type) { - case SDL_MOUSEMOTION: { mouseX = event.motion.x; + case SDL_MOUSEMOTION: { b=(b==0)?1:0; mouseX = event.motion.x; mouseY = event.motion.y;break; } - case SDL_MOUSEBUTTONDOWN: { permission=0;err=mouse_action (&gInit, mouseX, mouseY,camera.x,camera.y ); + case SDL_MOUSEBUTTONDOWN: { b=(b==0)?1:0; permission=0;err=mouse_action (&gInit, mouseX, mouseY,camera.x,camera.y ); if(err!=0){return err;} break;} case SDL_QUIT : { |