diff options
author | Damien Appert <dappert> | 2010-11-09 19:45:11 +0000 |
---|---|---|
committer | Damien Appert <dappert> | 2010-11-09 19:45:11 +0000 |
commit | 83d95e54cf3ee55f382475ec15375e5b467ab145 (patch) | |
tree | 8da03ce519164c53d1b3fad0da99a0b43e8f748e /sdl-test | |
parent | 108bf7d9f6087807595f1febd09d59d5d705ff59 (diff) | |
download | 2010-netlemmings-83d95e54cf3ee55f382475ec15375e5b467ab145.tar.gz 2010-netlemmings-83d95e54cf3ee55f382475ec15375e5b467ab145.tar.bz2 2010-netlemmings-83d95e54cf3ee55f382475ec15375e5b467ab145.zip |
mega up + cursor
git-svn-id: file:///var/svn/2010-netlemmings/trunk@147 077b3477-7977-48bd-8428-443f22f7bfda
Diffstat (limited to 'sdl-test')
4 files changed, 186 insertions, 82 deletions
diff --git a/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_integrees.c b/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_integrees.c index ee48f19..0869d2b 100644 --- a/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_integrees.c +++ b/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_integrees.c @@ -31,10 +31,10 @@ int init() return 3; } - pSpr_LemBackup = SDL_CreateRGBSurface(SDL_SWSURFACE, LEVEL_WIDTH, LEVEL_HEIGHT, + pSprLemBack = SDL_CreateRGBSurface(SDL_SWSURFACE , LEVEL_WIDTH, LEVEL_HEIGHT, SCREEN_BPP,0,0,0,0); - if( pSpr_LemBackup == NULL ) { + if( pSprLemBack == NULL ) { return 3; } pStencil = SDL_CreateRGBSurface(SDL_SWSURFACE, LEVEL_WIDTH, LEVEL_HEIGHT, diff --git a/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c b/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c index 7e3cf29..1b80fa9 100644 --- a/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c +++ b/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c @@ -1704,6 +1704,13 @@ int stateLemming(struct gameInit *gInit){ //miniMap gInit->mapI.miniMapLem=NULL; + + //curseur + gInit->mapI.cross.oldX=0; + gInit->mapI.cross.oldY=0; + gInit->mapI.cross.sizeC=0; + gInit->mapI.cross.numScreen=0; + gInit->mapI.cross.imgC=NULL; //MaxFallDistance gInit->mapI.nbrEntry=0; @@ -2037,9 +2044,7 @@ int stateLemming(struct gameInit *gInit){ int miniMapLemming (struct gameInit *gInit){ - int i,j,stepScreenX,stepScreenY,sizeMiniMapPixel_X,sizeMiniMapPixel_Y,w0,h0,x,y; - SDL_Rect rect; - SDL_Rect to; + int i,j,stepScreenX,stepScreenY; Uint32 err; //int cpt=0; @@ -2074,7 +2079,6 @@ int stateLemming(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; @@ -2465,63 +2469,41 @@ 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_FillRect( pSpr_LemBackup, &offset, gInit->mapI.map.cmap.bgColor, 0); - if(err!=0){return err;}*/ - - /*test_blit(sf, &rStencil, pSpr_Lem, &offset,0)) != 0){ - //-DEBUG-printf("ERREUR [%d] test_blit : ",err); - return err; - }*/ err=test_blit(sf, &rStencil, pSpr_Lem, &offset,0); - if(err != 0){ - //-DEBUG-printf("ERREUR [%d] test_blit : ",err); - return err; - } - /* - err=test_blit(sf, &rStencil, pSpr_LemBackup, &offset,0); - if(err != 0){ - //-DEBUG-printf("ERREUR [%d] test_blit : ",err); - return err; - }*/ + 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; } - /* - k=gInit->l.ll; - while(k!=NULL){ - k->data.pl->oldX=k->x; - k->data.pl->oldY=k->y; - rStencil.x=k->x; //data.pl->oldX; - rStencil.y=k->y; //data.pl->oldX; - rStencil.w=k->data.pl->imgF->w; - rStencil.h=k->data.pl->imgF->h; - test_blit(pSpr_Lem,&rStencil, k->data.pl->imgF, NULL,0); - k=k->next; - }*/ - }//for passage ///FIN TEST: SPR + // err=test_blit(pSprLemBack, NULL, pSpr_Lem, NULL,0); + // if(err != 0){return err;} return 0; } int paint_objet_Init (struct gameInit *gInit){ - SDL_Rect offset,objetAnim,rStencil; SDL_Surface *sf; struct listeSimplementChainee *k=NULL; - int err=0,i,of; - int type=0,size; + int err=0,of; + int type=0; //int ox,oy; //passage==0 => no dig //passage==1 => rest - int passage; int mode=0; int yToH,xToW,fit,hf; - Uint32* temp_pixels= NULL; //Uint32 color,color2,color3; //int size; //void *temp_pixels = NULL; @@ -2563,20 +2545,32 @@ int stateLemming(struct gameInit *gInit){ 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){ + if((err!=gInit->mapI.map.cmap.bgColor)||(((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==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 + ((Uint32 *)k->data.po->img->pixels)[xToW+yToH*sf->w+(hf*fit*sf->w)]=err; + } else { + 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 + } + } } } } } //gInit->mapI.map.cmap.bgColor + SDL_SetColorKey(k->data.po->img, SDL_SRCCOLORKEY |SDL_RLEACCEL, gInit->mapI.map.cmap.bgColor); + //SDL_SetColorKey(k->data.po->img, SDL_SRCCOLORKEY|SDL_RLEACCEL, ccc_keyGif); k=k->next; } ///FIN TEST: SPR @@ -2584,18 +2578,15 @@ int stateLemming(struct gameInit *gInit){ } int paint_objet_stencil (struct gameInit *gInit, int cptFps){ - SDL_Rect offset,objetAnim,rStencil; + SDL_Rect offset,objetAnim; SDL_Surface *sf; struct listeSimplementChainee *k=NULL; //int res; int err=0; int type=0; - int ox,oy,i,of; - int mode=0; + int i; int cptSteel; - Uint32 ccc_temp,color,color2;//,color3; - //int size; - //void *temp_pixels = NULL; + Uint32 ccc_temp=0x0; //DEBUT TEST: SPR k=gInit->o.lo; while ( k !=NULL ) { @@ -2798,14 +2789,11 @@ int paint_lemming (struct gameInit *gInit, int cptFps){ SDL_Rect offset,objetAnim,rect; SDL_Surface *sf; struct listeSimplementChainee *k=NULL; - int res; int err=0; - int cpt=0; int newID; int fx,fy,fs,la,ls;//lt; k=gInit->l.ll; - while ( k !=NULL ) { // //-DEBUG-printf("ID= %d k->data.pl->cptState== %d\n",k->ID,k->data.pl->cptState); // DIED @@ -2886,21 +2874,6 @@ int paint_lemming (struct gameInit *gInit, int cptFps){ } default:break; } - - 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->data.pl->oldX=k->x; - k->data.pl->oldY=k->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(pSpr_Lem,&rect, k->data.pl->imgF, NULL,0); - test_blit(sf, &objetAnim, pSpr_Lem, &offset,0); } @@ -3045,11 +3018,44 @@ int findTerrain( struct gameInit *gInit,int x, int y, int x0){ int paint_cursor(SDL_Surface *dst1, SDL_Surface *src, int x, int y, int x0, struct gameInit *gInit) { - SDL_Rect from, to; + SDL_Rect from, to, before; int f=0; 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; + test_blit(gInit->mapI.cross.imgC, NULL, pSpr_Lem, &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; + from.w=gInit->mapI.cross.imgC->w; + from.h=gInit->mapI.cross.sizeC; + test_blit(gInit->mapI.cross.imgC, NULL, pSpr_Lem, &to,0); + + to.x=gInit->mapI.cross.oldXI; + to.y=gInit->mapI.cross.oldY-LEVEL_HEIGHT; + from.y=gInit->mapI.cross.sizeC; + from.w=gInit->mapI.cross.imgC->w; + from.h=gInit->mapI.cross.imgC->h-gInit->mapI.cross.sizeC; + test_blit(gInit->mapI.cross.imgC, NULL,pInterface, &to,0); + + } + /* Render! */ from.x = 0; from.h = src->h/8; @@ -3060,6 +3066,15 @@ 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; + to.w=gInit->mapI.cross.imgC->w; + to.h=gInit->mapI.cross.imgC->h; + gInit->mapI.cross.numScreen=0; + test_blit(pInterface, &to, gInit->mapI.cross.imgC, NULL,0); + test_blit(src, &from, pInterface, &to,0); } else { k=gInit->l.ll; @@ -3101,11 +3116,34 @@ 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; + before.w=gInit->mapI.cross.imgC->w; + gInit->mapI.cross.sizeC=( ((LEVEL_HEIGHT-y-from.h)<0)? gInit->mapI.cross.imgC->h-LEVEL_HEIGHT-y-from.h : gInit->mapI.cross.imgC->h ); + before.h=gInit->mapI.cross.sizeC; + gInit->mapI.cross.numScreen=1; + test_blit(dst1, &before, gInit->mapI.cross.imgC, NULL,0); + test_blit(src, &from, dst1, &to,0); if(y+from.h>LEVEL_HEIGHT){ 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; + + before.x=gInit->mapI.cross.oldXI=to.x; + before.y=gInit->mapI.cross.sizeC; + before.w=gInit->mapI.cross.imgC->w; + before.h=gInit->mapI.cross.imgC->h-gInit->mapI.cross.sizeC; + + gInit->mapI.cross.numScreen=2; + test_blit(pInterface, &to, gInit->mapI.cross.imgC, &before,0); + test_blit(src, &from, pInterface, &to,0); } } @@ -3324,11 +3362,31 @@ int mouse_action (struct gameInit *gInit, int x, int y, int camX, int camY ){ int supprLem (struct gameInit *gInit, int cptFps){ struct listeSimplementChainee *k=NULL; + SDL_Rect rect; // refresh liste all of 100 tick if(cptFps % 100 == 0) { 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; + k->data.pl->oldY=k->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;} @@ -3358,6 +3416,30 @@ 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; + k->data.pl->oldY=k->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; + } + } return 0; } @@ -3370,7 +3452,7 @@ int lancement (){ int err=0; //Ce qui va nous permettre de quitter int quit = 0; - SDL_Rect camera,inter,miniMapR,test,rect; + SDL_Rect camera,inter,miniMapR; int mouseX,mouseY=0; long tick,temps=0; float fps = 0.0; @@ -3383,7 +3465,6 @@ int lancement (){ //La structure d'evenement SDL_Event event; event.type=0; - struct listeSimplementChainee *k; //event.key.keysym.sym=0; //paint_stencil=1; @@ -3424,8 +3505,14 @@ 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_SWSURFACE, 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); + SDL_SetColorKey(pTerrain, SDL_SRCCOLORKEY|SDL_RLEACCEL, ccc_bgStencil); mouseX = gInit.mapI.xPos; camera.x=gInit.mapI.xPos; @@ -3474,9 +3561,11 @@ int lancement (){ //<-- //Tant que l'utilisateur n'a pas quitter test_FillRect( pSpr_Lem, NULL, gInit.mapI.map.cmap.bgColor,0); - test_FillRect( pSpr_LemBackup, 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, pSpr_LemBackup, 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); @@ -3554,8 +3643,8 @@ int lancement (){ 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){ diff --git a/sdl-test/SDL_tuto/TestParserLemmingsLVL/genereTerrain.sh b/sdl-test/SDL_tuto/TestParserLemmingsLVL/genereTerrain.sh index b64287b..0fb0d65 100755 --- a/sdl-test/SDL_tuto/TestParserLemmingsLVL/genereTerrain.sh +++ b/sdl-test/SDL_tuto/TestParserLemmingsLVL/genereTerrain.sh @@ -180,9 +180,12 @@ do fi #echo "numObjet ==> $numObjet" if [ $numObjetTest -eq 99 ] - then typeObjet=$(echo $k | tr '-' ' ' | cut -f2 -d'=' | cut -f2 -d' ') + then typeObjet=$(echo $k | tr '-' ' ' | cut -f2 -d'=' | cut -f2 -d' ' ) else typeObjet=$(grep "type_$numObjet" $path/$style/$style.ini | cut -f2 -d'=' | cut -f2 -d' ') fi + + typeObjet=$(echo "$typeObjet" | sed -e "s/\\n//g" | sed -e "s/\\r//g" ) + #echo "typeObjet ==> $typeObjet" wObjet=$(giftopnm -comment $path/$style/$style"o_"$numObjet".gif" | head -n2 | tail -n1 | cut -f1 -d' ' ) @@ -385,8 +388,8 @@ cat ./Source/lvlStyleT.ini >> $pathDst/lvl200$numStyle.ini rm ./Source/lvlStyleT.ini #Name -echo "name = test $style -" >> $pathDst/lvl200$numStyle.ini +#typeObjet=$(echo "$typeObjet" | sed -e "s/\\n//") +echo "name = Test $style($numStyle) O($numObjet) T($typeObjet) M($mode) " >> $pathDst/lvl200$numStyle.ini exit 0 diff --git a/sdl-test/SDL_tuto/TestParserLemmingsLVL/parse_ini.yy b/sdl-test/SDL_tuto/TestParserLemmingsLVL/parse_ini.yy index a5006fe..12acf9a 100644 --- a/sdl-test/SDL_tuto/TestParserLemmingsLVL/parse_ini.yy +++ b/sdl-test/SDL_tuto/TestParserLemmingsLVL/parse_ini.yy @@ -158,7 +158,7 @@ SDL_Surface *pTerrain = NULL; //Fond avec juste la map SDL_Surface *pSpr_Lem = NULL; // Fond + animations + Lemming - SDL_Surface *pSpr_LemBackup = NULL; // Fond + animations + SDL_Surface *pSprLemBack = NULL; // Fond + animations SDL_Surface *screen = NULL; // Ecran via la caméra SDL_Surface *pInterface = NULL; // Ecran du bas SDL_Surface *pStencil= NULL; // Ecran Stencil @@ -353,6 +353,17 @@ "numBuilders","numBashers","numMiners","numDiggers" }; + struct cursor { + + int oldX; // positionX du cuseur;default=0 + int oldY; // positionY du cuseur;default=0 + int oldXI; // positionX dans l'interface; default=0; + int sizeC; // dans le cas où le curseur est à cheval entre 2 Surface + int numScreen; // num ecran; default=0 + SDL_Surface *imgC; // image de l'objet; default=NULL; + + }; + struct infoMap { char* name; // map name; default=NULL; int paraMap[IDENT_COUNT]; // some parameter of this map @@ -361,6 +372,7 @@ 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; + struct cursor cross; // info cursor struct mapStyle map; // map struct lemmingJobAndSprite *lemmingDATA; // DATA of lemmingJob; default=NULL; }; |