diff options
author | Damien Appert <dappert> | 2010-11-18 17:42:09 +0000 |
---|---|---|
committer | Damien Appert <dappert> | 2010-11-18 17:42:09 +0000 |
commit | 895e96ddd85e36947c4048e31cde428fdb260664 (patch) | |
tree | 4e0c1a9af15335bcc35492582fd2a8b8e68b4ec6 /sdl-test | |
parent | 190ba402d9a19e6cee7e3b893fc5df7c868d6b85 (diff) | |
download | 2010-netlemmings-895e96ddd85e36947c4048e31cde428fdb260664.tar.gz 2010-netlemmings-895e96ddd85e36947c4048e31cde428fdb260664.tar.bz2 2010-netlemmings-895e96ddd85e36947c4048e31cde428fdb260664.zip |
timerr
git-svn-id: file:///var/svn/2010-netlemmings/trunk@159 077b3477-7977-48bd-8428-443f22f7bfda
Diffstat (limited to 'sdl-test')
-rw-r--r-- | sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c | 71 | ||||
-rw-r--r-- | sdl-test/SDL_tuto/TestParserLemmingsLVL/parse_ini.yy | 12 |
2 files changed, 53 insertions, 30 deletions
diff --git a/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c b/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c index d13ef7c..aa3f15a 100644 --- a/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c +++ b/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c @@ -1060,9 +1060,10 @@ int stateLemming(struct gameInit *gInit){ return 0; } - int print_num(SDL_Surface *dst, SDL_Surface *src, int x, int y, int value) + int print_num(SDL_Surface *dst, SDL_Surface *src, int x, int y, int value, int nbrMaxOfChiffre) { char buf[9]; + SDL_Rect to; int i,r,v,p=0; int max = 1000000000; SDL_Rect from; @@ -1089,14 +1090,22 @@ int stateLemming(struct gameInit *gInit){ for(i = 0; i < p; ++i) { - SDL_Rect to; to.x = x + i * (from.w + 2); to.y = y; from.y = buf[i] * (from.h); test_blit(src, &from, dst, &to,0); } - return 0; - } + + for(i = p; i < nbrMaxOfChiffre; ++i) + { + to.x = x + i * (from.w + 2); + to.y = y; + test_FillRect( dst, &to, 0, 0); + //test_blit(src, &from, dst, &to,0); + } + + return 0; +} int paint_bomber(int x,int y,int xMax,SDL_Surface *cooldown,SDL_Surface *dst,int cpt){ @@ -1130,7 +1139,7 @@ int stateLemming(struct gameInit *gInit){ to.x = x + (i%40)*16; to.y = y + from.h * (i/40); test_blit(src, &from, dst, &to,0); - //print_num(screen, src2, to.x + 20, to.y, i); + //print_num(screen, src2, to.x + 20, to.y, i, 3); } return 0; @@ -1743,15 +1752,18 @@ int stateLemming(struct gameInit *gInit){ gInit->s.ls=NULL; gInit->l.ll=NULL; - //boostFps - gInit->boostFps=0; // init button state for(i=0;i<NBR_CPT;++i){ gInit->cptGame[i]=0; } gInit->cptGame[17]=-1; - + + // init Timerr + //tps.boostFps + gInit->tps.boostFps=0; + gInit->tps.decalTime=0; + gInit->tps.totalTime=0; // init InfoMap // map name gInit->mapI.name = NULL; @@ -3053,8 +3065,8 @@ int findTerrain( struct gameInit *gInit,int x, int y, int x0){ (y+15 <= k->y + sf->h)&& (y+15 > k->y)){//on the terrain ++cpt; - print_num(pInterface, gInit->mapI.map.tabGif[1], 5 , pInterface->h-10, cpt); - print_num(pInterface, gInit->mapI.map.tabGif[1], 5 + cpt*40, pInterface->h-10, i); + print_num(pInterface, gInit->mapI.map.tabGif[1], 5 , pInterface->h-10, cpt,2); + print_num(pInterface, gInit->mapI.map.tabGif[1], 5 + cpt*40, pInterface->h-10, i,3); to.x=k->x; to.y=k->y; to.w=sf->w; @@ -3075,7 +3087,7 @@ int findTerrain( struct gameInit *gInit,int x, int y, int x0){ to.w=sf->w; to.h=1; test_FillRect(pStencil, &to, ccc_red,0); - err=print_num(pStencil, gInit->mapI.map.tabGif[1], k->x + 2, k->y + 2, i); + err=print_num(pStencil, gInit->mapI.map.tabGif[1], k->x + 2, k->y + 2, i,3); if(err!=0){return err;} } @@ -3338,13 +3350,13 @@ int paint_interface (struct gameInit *gInit){ if(i+4 < 12){ n=gInit->mapI.paraMap[i+4]; err=print_num(pInterface, gInit->mapI.map.tabGif[1], (to.x+7+(((n/10)>0)?0:5))+(sf->w*(2)), to.y-12, - n); + n,2); if(err!=0){return err;} } test_blit(sf, &from, pInterface, &to,0); } n=gInit->mapI.paraMap[0]; - err=print_num(pInterface, 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,2); if(err!=0){return err;} return 0; } @@ -3400,7 +3412,7 @@ int mouse_action (struct gameInit *gInit, int x, int y, int camX, int camY ){ } //SPEED ; BOOST FPS if(numB==12){ - gInit->boostFps=((gInit->boostFps > FPS)? gInit->boostFps - 4*FPS : gInit->boostFps + 4*FPS ); + gInit->tps.boostFps=((gInit->tps.boostFps > FPS)? gInit->tps.boostFps - 4*FPS : gInit->tps.boostFps + 4*FPS ); } for(i=0;i<NBR_BUTTON_LEMMING;++i){ @@ -3717,10 +3729,10 @@ int lancement (){ while( SDL_PollEvent( &event ) ) { switch(event.key.keysym.sym){ - 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_HOME : gInit.tps.boostFps = 0; break; + case SDLK_END : gInit.tps.boostFps = FPS-11; break; + case SDLK_PAGEUP : if(gInit.tps.boostFps>0){gInit.tps.boostFps -=1;}break; + case SDLK_PAGEDOWN : 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 :{ @@ -3869,32 +3881,35 @@ int lancement (){ } */ // limte fps - temps = SDL_GetTicks(); + //temps = SDL_GetTicks(); + + if(cptFps%FPS==0) {gInit.tps.totalTime+=1000;} + //heure - err=print_num(pInterface, gInit.mapI.map.tabGif[1], pInterface->w-160, pInterface->h-40, temps/(1000*3600)); + err=print_num(pInterface, gInit.mapI.map.tabGif[1], pInterface->w-160, pInterface->h-40, gInit.tps.totalTime/(1000*3600), 2); if(err!=0){return err;} //minute - err=print_num(pInterface, gInit.mapI.map.tabGif[1], pInterface->w-130, pInterface->h-40, (temps/(1000*60))%60); + err=print_num(pInterface, gInit.mapI.map.tabGif[1], pInterface->w-130, pInterface->h-40, (gInit.tps.totalTime/(1000*60))%60, 2); if(err!=0){return err;} //seconde - err=print_num(pInterface, gInit.mapI.map.tabGif[1], pInterface->w-100, pInterface->h-40, (temps/1000)%60); + err=print_num(pInterface, gInit.mapI.map.tabGif[1], pInterface->w-100, pInterface->h-40, (gInit.tps.totalTime/1000)%60, 2); if(err!=0){return err;} - err=print_num(pInterface, gInit.mapI.map.tabGif[1], pInterface->w-150, pInterface->h-10, cptFps); + err=print_num(pInterface, gInit.mapI.map.tabGif[1], pInterface->w-150, pInterface->h-10, cptFps, 5); if(err!=0){return err;} - err=print_num(pInterface, gInit.mapI.map.tabGif[1], pInterface->w-87, pInterface->h-10, fps); + err=print_num(pInterface, gInit.mapI.map.tabGif[1], pInterface->w-87, pInterface->h-10, fps, 3); if(err!=0){return err;} - err=print_num(pInterface, gInit.mapI.map.tabGif[1], pInterface->w-37, pInterface->h-10, FPS+gInit.boostFps); + err=print_num(pInterface, gInit.mapI.map.tabGif[1], pInterface->w-37, pInterface->h-10, FPS+gInit.tps.boostFps, 3); if(err!=0){return err;} test_blit(pInterface, NULL , screen, &inter,0); - if(FPS+gInit.boostFps <= 0){//-DEBUG-printf("BUG: FPS %d +gInit.boostFps %d <= 0",FPS,gInit.boostFps); + if(FPS+gInit.tps.boostFps <= 0){//-DEBUG-printf("BUG: FPS %d +gInit.tps.boostFps %d <= 0",FPS,gInit.tps.boostFps); return(42); } else { - while(((float)fps_count * 1000.0 / (SDL_GetTicks()-fps_start) > FPS+gInit.boostFps) ){ - if((FPS+gInit.boostFps)<=120){// useless ? + while(((float)fps_count * 1000.0 / (SDL_GetTicks()-fps_start) > FPS+gInit.tps.boostFps) ){ + if((FPS+gInit.tps.boostFps)<=120){// useless ? SDL_Delay(3); } }} diff --git a/sdl-test/SDL_tuto/TestParserLemmingsLVL/parse_ini.yy b/sdl-test/SDL_tuto/TestParserLemmingsLVL/parse_ini.yy index d40a418..69628cc 100644 --- a/sdl-test/SDL_tuto/TestParserLemmingsLVL/parse_ini.yy +++ b/sdl-test/SDL_tuto/TestParserLemmingsLVL/parse_ini.yy @@ -463,6 +463,14 @@ struct listeSimplementChainee *ll; // list of lemming; default=NULL; }; + struct timerr { + + int boostFps; // grow up FPS *5; default=0; + int decalTime; // decalage induit par l'acceleration des FPS; default=0; + int totalTime; // temps passé dans le jeu; defautl=0; + + }; + // game use some cpt #define NBR_CPT 20 @@ -472,7 +480,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; + struct timerr tps; // gestion of time // 0-13 : BUTTON_LEMMING state button 0: off; 1: on; // 14 : CURSOR STATE // 15 : FREE CPT: for all need it ...; default=0; @@ -570,7 +578,7 @@ int paint_cursor(SDL_Surface *dst1, SDL_Surface *src, int x, int y, int x0, struct gameInit *gInit); - int print_num(SDL_Surface *dst, SDL_Surface *font, int x, int y, int value); + int print_num(SDL_Surface *dst, SDL_Surface *font, int x, int y, int value, int nbrMaxOfChiffre); int print_alpha(SDL_Surface *dst, SDL_Surface *src, int x, int y, char* msg); |