summaryrefslogtreecommitdiff
path: root/sdl-test
diff options
context:
space:
mode:
authorDamien Appert <dappert>2010-11-02 11:18:59 +0000
committerDamien Appert <dappert>2010-11-02 11:18:59 +0000
commit4f086dc29744f3ab893746bdb2aefdadae3dcf43 (patch)
tree6642b200e63a4f7e8b8bff7e25514dfe0cf6415e /sdl-test
parent71120df4c9e3b0fe999c232b912fb1826dcc015e (diff)
download2010-netlemmings-4f086dc29744f3ab893746bdb2aefdadae3dcf43.tar.gz
2010-netlemmings-4f086dc29744f3ab893746bdb2aefdadae3dcf43.tar.bz2
2010-netlemmings-4f086dc29744f3ab893746bdb2aefdadae3dcf43.zip
moult amelioration: loupe, automate, algo, cursor
git-svn-id: file:///var/svn/2010-netlemmings/trunk@130 077b3477-7977-48bd-8428-443f22f7bfda
Diffstat (limited to 'sdl-test')
-rw-r--r--sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c2767
-rw-r--r--sdl-test/SDL_tuto/TestParserLemmingsLVL/parse_ini.yy22
2 files changed, 1462 insertions, 1327 deletions
diff --git a/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c b/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c
index 9bf4d27..b286a97 100644
--- a/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c
+++ b/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c
@@ -1,6 +1,7 @@
-
// Est inclus en direct dans parse_ini.yy
+
Uint32 string_to_Uint32 (char* c,int taille){
+
Uint32 u32c;
int i,n,lc = strlen(c);
int t[taille];
@@ -11,7 +12,7 @@ Uint32 string_to_Uint32 (char* c,int taille){
u32c = 0;
for(i=0;i<taille;++i){
n = c[i+2];
- ////-DEBUG-printf("n = %d, %c\n",n);
+ //-DEBUG-printf("n = %d, %c\n",n);
if (n > 47 && n < 58 ) { t[i]=(n - 48) ;}
if (n > 64 && n < 71 ) { t[i]=(n - 55) ;}
if (n > 96 && n < 103 ){ t[i]=(n - 87) ;}
@@ -83,8 +84,8 @@ struct listeSimplementChainee* rev_listeO (struct listeSimplementChainee* liste)
// returne le state de l'oblet a afficher
int anim_objet(int typeS, int typeO, int cptFps, int frames, int *cpt, struct gameInit *gInit){
int f=0;
- if(typeS == 90){typeS=4;}//Lemming anim continue
- if(typeS == 91){typeS=5;}//Lemming anim at once
+ if(typeS == 90){typeS=1;}// 4 //Lemming anim continue
+ if(typeS == 91){typeS=2;}// 5 //Lemming anim at once
switch(typeS){
// not animed
case 0 : break;//f=0
@@ -155,7 +156,7 @@ inline Uint32 get_pixel32( int x, int y, SDL_Surface *surface )
{
//Convertie les pixels en 32 bit
Uint32 *pixels = (Uint32 *)surface->pixels;
- ////-DEBUG-printf("4) x=%d,y=%d,p =%X\n",x,y,pixels[ ( y * surface->w ) + x ]);
+ //-DEBUG-printf("4) x=%d,y=%d,p =%X\n",x,y,pixels[ ( y * surface->w ) + x ]);
//Recupere le pixel demande
/*//-DEBUG-printf("out get_pixel32 !! => (((y %d * surface->w %d ) + x %d) => %d >= surface->h %d *surface->w %d = %d)\n",y,surface->w,x,(y * surface->w ) + x,surface->h,surface->w,surface->h*surface->w);*/
@@ -251,11 +252,17 @@ int checkPixelDOWN(int nbr, int x, int y){
err=get_pixel32(x,yb+res,pStencil);
if(err==ccc_error){return 113;}
- ////-DEBUG-printf("res %d\n",res);
+ //-DEBUG-printf("res %d\n",res);
+
+ if((err==ccc_oNoDigLeft)||(err==ccc_oNoDigRight)){
+ return res;
+ }
if((err&0xbb)!=0xbb){// it's not an object
- if(err!=ccc_bgStencil){
- return res;//return ((res == 0)? 0 : res-1);//res;
+ if((err&0xcb)!=0xcb){// it's not a blocker
+ if(err!=ccc_bgStencil){
+ return res;//return ((res == 0)? 0 : res-1);//res;
+ }
}
}
}
@@ -283,9 +290,14 @@ int checkPixelUP(int nbr, int x, int y, int size ){
err=get_pixel32(x,ym-res,pStencil);
if(err==ccc_error){return 113;}
+ if((err==ccc_oNoDigLeft)||(err==ccc_oNoDigRight)){
+ return res;
+ }
if((err&0xbb)!=0xbb){// it's not an object
- if(err!=ccc_bgStencil){
- return res;//return ((res == 0)? 0 : res-1);//res;
+ if((err&0xcb)!=0xcb){// it's not a blocker
+ if(err!=ccc_bgStencil){
+ return res;//return ((res == 0)? 0 : res-1);//res;
+ }
}
}
}
@@ -325,11 +337,12 @@ int aboveGround(int x, int y) {
err=get_pixel32(x,y-res,pStencil);
if(err==ccc_error){return 114;}
-
-
+
+ if(!((err==ccc_oNoDigLeft)||(err==ccc_oNoDigRight))){
if((err&0xbb)==0xbb){//it'an object
return res;
}
+ }
if((err&0xcb)==0xcb){// it's a blocker
return res;
}
@@ -357,15 +370,19 @@ int reachedPlateau(int x, int y, int size, int dir) {
if (ym>= LEVEL_HEIGHT || ym<0)
return 0;
- if (dir == 0)//LEFT
- x -= 2;
+ if (dir == 1)//RIGHT
+ x += 3;
else
- x += 2;
+ x += 3;
putPixel(pSpr_Lem,x,y,ccc_yellow);
err=get_pixel32(x,y,pStencil);
if(err==ccc_error){return 115;}
+
+ if((err==ccc_oNoDigLeft)||(err==ccc_oNoDigRight)){
+ return 0;
+ }
if((err&0xbb)==0xbb){//it'an object
return 1;
@@ -376,15 +393,6 @@ int reachedPlateau(int x, int y, int size, int dir) {
if(err==ccc_bgStencil){
return 1;
}
- /*
-
- if((err&0xbb)!=0xbb){
-//if(err!=(ccc_lWalk_on & ccc_bgStencil)){
-if((err|ccc_lWalk_on)!=ccc_bgStencil){
-return 1;
-}
-}
- */
return 0;
}
@@ -414,10 +422,9 @@ int turnedByStopper(int x, int y, int dir) {
Uint32 err;
err=stencilMid(x,y);
if(err==ccc_error){return 116;}
- if(err==ccc_lWalk_on){return 2;}
-
- ////-DEBUG-printf("err %p\n",err);
+ //-DEBUG-printf("err %p\n",err);
+
if (err == ccc_lStopperLeft && dir==1) {//Right
//LEFT;
return 0;
@@ -476,17 +483,19 @@ int stateLemming(struct gameInit *gInit){
lh=sfT->h/lState;
lw=sfT->w;
-
+
oldX=k->x;
oldType=k->ID;
newType=k->ID;
+
// cooldown before lemming boom
boom=0;
switch(k->data.pl->cptBoom){
case 0: boom=1;break;
- case 404: break;
+ case -1: break;
default: {
+ //printf("k->data.pl->cptBoom %d\n",k->data.pl->cptBoom);
--k->data.pl->cptBoom;
if(paint_bomber(k->x,k->y,lw,gInit->mapI.map.tabGif[2],pSpr_Lem,(k->data.pl->cptBoom/FPS +1))!=0){return 99;}
}
@@ -504,6 +513,7 @@ int stateLemming(struct gameInit *gInit){
}
//if (selectCtr>0) {selectCtr--;}
if (flip) {k->data.pl->dir = (k->data.pl->dir==1) ? 0 : 1 ;}
+
switch(k->ID){
case 3 : // climber_to_walker
@@ -513,6 +523,11 @@ int stateLemming(struct gameInit *gInit){
k->ID=10;//BOMBER
break;
}
+ if(k->data.pl->cptState>0)
+ {break;}
+ else
+ {k->ID=1;}
+
case 1 : // faller
{//-DEBUG-printf("faller ->");
if(boom){
@@ -520,7 +535,7 @@ int stateLemming(struct gameInit *gInit){
k->ID=10;//BOMBER
break;
}
- ////-DEBUG-printf("x =%d y =%d x+fx= %d, y+fy =%d \n",k->x,k->y,k->x+fx,k->y+fy);
+ //-DEBUG-printf("x =%d y =%d x+fx= %d, y+fy =%d \n",k->x,k->y,k->x+fx,k->y+fy);
free=checkPixelDOWN(FALLER_STEP, k->x+fx,k->y+fy);
if(free==113){return 113;}
if(free==FALL_DISTANCE_FORCE_FALL)
@@ -625,11 +640,14 @@ int stateLemming(struct gameInit *gInit){
}
} else {
k->x=oldX;
- if(k->data.pl->climber==1){
- k->ID=2; // CLIMBER
- break;
- } else {
- k->data.pl->dir = (k->data.pl->dir==1) ? 0 : 1 ;
+ if(free==0){
+ if(k->data.pl->climber==1){
+ k->ID=2; // CLIMBER
+ k->x+=((k->data.pl->dir==1) ? 1 : -1 );
+ break;
+ } else {
+ k->data.pl->dir = (k->data.pl->dir==1) ? 0 : 1 ;
+ }
}
}
if(free>0){
@@ -701,18 +719,22 @@ int stateLemming(struct gameInit *gInit){
if ( (++(k->data.pl->cptFall) & 1) == 1) // only every other step
{k->y -= CLIMBER_STEP;}
//fa=(k->data.pl->dir==1) ? 4 : 3 ;
- err=checkPixelUP(2,k->x+fx+3,k->y+fy,fs);
+ err=checkPixelUP(2,k->x+fx+((k->data.pl->dir==1) ? 2 : 4 ),k->y+fy,fs);
if(err==113){return 127;}
if (midY(k->y+fy,fs) < 0 || err<2) {
k->data.pl->dir = (k->data.pl->dir==1) ? 0 : 1 ;
k->ID=1; //FALLER;
+ //-DEBUG-printf("C->FALLER\n");
k->data.pl->cptFall = 0;
} else {
- err=reachedPlateau(k->x+fx+3,k->y+fy,fs,k->data.pl->dir);
+ err=reachedPlateau(k->x+fx,k->y+fy,fs,k->data.pl->dir);
if (err==115){return 115;}
- if(err) {
+ if(err==1) {
k->data.pl->cptFall = 0;
k->ID=3; //CLIMBER_TO_WALKER;
+ k->data.pl->cptState=gInit->mapI.lemmingDATA[newID].state;
+ k->x+=((k->data.pl->dir==1) ? 1 : -1 );
+ //-DEBUG-printf("C->CLIMBER_TO_WALKER\n");
}
}
break;
@@ -912,13 +934,22 @@ int stateLemming(struct gameInit *gInit){
free=checkPixelDOWN(FLOATER_STEP, k->x+fx,k->y+fy);
if(free==113){return 113;}
if(free>0){
+ k->ID=1;//FALLER
+ }
+ if(boom){
k->ID=10;//BOMBER
- } else {break;}
+ if(!gInit->mapI.nuke){
+ //-DEBUG-printf("Play Sound SND_EXPLODE\n");
+ //GameController.sound.play(GameController.SND_EXPLODE);
+ }
+ } else {
+ break;
+ }
case 10: // BOMBER
//-DEBUG-printf("BOMBER ->");
if(k->data.pl->cptBoom==0){
- k->data.pl->cptBoom=404;
+ k->data.pl->cptBoom=-1;
k->data.pl->cptState=gInit->mapI.lemmingDATA[10].state;
}
free=checkPixelDOWN(FLOATER_STEP, k->x+fx,k->y+fy);
@@ -930,14 +961,14 @@ 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==16){
+ if(k->data.pl->cptState==(gInit->mapI.lemmingDATA[10].state-2)){//16){
err=ereasePx(k->x,k->y,gInit->mapI.map.tabGif[10],gInit->mapI.map.cmap.bgColor);
if(err!=0){return err;}
//TODO
}
break;
- default:
+ default:
//-DEBUG-printf("default ->");
if(boom){
explode (k->x+fx,k->y+fy,fs);
@@ -945,1525 +976,1612 @@ int stateLemming(struct gameInit *gInit){
break;
}
break;
- }//FIN SWITCH
+ }//FIN SWITCH
- // trap
- if(k->ID != 7 && k->ID != 8 && k->ID != 9 && k->ID != 17){
- err=get_pixel32(k->x+fx,k->y,pStencil);
- if(err==ccc_error){return 12;}
- ////-DEBUG-printf("k->ID => %d get_pixel32(k->x %d+fx %d => %d,k->y %d,pStencil) == %p \n",k->ID,k->x,fx,k->x+fx,k->y,err);
- if(err==ccc_oTrapDrown){
- k->ID=7;
- k->data.pl->cptState=gInit->mapI.lemmingDATA[k->ID].state;
- }
- if(err==ccc_oTrapAndLem){
- k->ID=8;
- k->data.pl->cptState=gInit->mapI.lemmingDATA[k->ID].state;
- }
- if(err==ccc_oTrapAndNoLem){
- k->ID=17;
- k->data.pl->cptState=0;
- o=gInit->o.lo;
- while(o!=NULL){
- ////-DEBUG-printf("gInit->mapI.map.tabDataSprO[%d].type=>%d\n(o->x%d<=(k->x+fx)%d)\n object->w %d >= (k->x+fx) %d\n o->y %d <= (k->y) %d\n",o->ID,gInit->mapI.map.tabDataSprO[o->ID].type,(o->x),(k->x+fx),gInit->mapI.map.tabGif[gInit->mapI.map.tiles*2+o->ID*2+o->data.po->UD+ADD_OBJ]->w,(k->x+fx),o->y,(k->y));
- if((gInit->mapI.map.tabDataSprO[o->ID].type==6)&&
- (o->x<=(k->x+fx))&&
- (gInit->mapI.map.tabGif[gInit->mapI.map.tiles*2+o->ID*2+o->data.po->UD+ADD_OBJ]->w+o->x >= (k->x+fx))&&
- (o->y<=(k->y))&&
- (gInit->mapI.map.tabGif[gInit->mapI.map.tiles*2+k->ID*2+k->data.po->UD+ADD_OBJ]->h+o->y >= (k->y))){
- o->data.po->cptState=gInit->mapI.map.tabDataSprO[o->ID].state;
- break;
+ // trap
+ if(k->ID != 7 && k->ID != 8 && k->ID != 9 && k->ID != 17){
+ //middle of lemming => pixel red
+ err=get_pixel32(k->x+lw/2,k->y+fy,pStencil);
+ if(err==ccc_error){return 12;}
+ //-DEBUG-printf("k->ID => %d get_pixel32(k->x %d+fx %d => %d,k->y %d,pStencil) == %p \n",k->ID,k->x,fx,k->x+fx,k->y,err);
+ if(err==ccc_oTrapDrown){
+ k->ID=7;
+ k->data.pl->cptState=gInit->mapI.lemmingDATA[k->ID].state;
+ }
+ if(err==ccc_oTrapAndLem){
+ k->ID=8;
+ k->data.pl->cptState=gInit->mapI.lemmingDATA[k->ID].state;
+ }
+ if(err==ccc_oTrapAndNoLem){
+ k->ID=17;
+ k->data.pl->cptState=0;
+ o=gInit->o.lo;
+ while(o!=NULL){
+ //-DEBUG-printf("gInit->mapI.map.tabDataSprO[%d].type=>%d\n(o->x%d<=(k->x+fx)%d)\n object->w %d >= (k->x+fx) %d\n o->y %d <= (k->y) %d\n",o->ID,gInit->mapI.map.tabDataSprO[o->ID].type,(o->x),(k->x+fx),gInit->mapI.map.tabGif[gInit->mapI.map.tiles*2+o->ID*2+o->data.po->UD+ADD_OBJ]->w,(k->x+fx),o->y,(k->y));
+ if((gInit->mapI.map.tabDataSprO[o->ID].type==6)&&
+ (o->x<=(k->x+fx))&&
+ (gInit->mapI.map.tabGif[gInit->mapI.map.tiles*2+o->ID*2+o->data.po->UD+ADD_OBJ]->w+o->x >= (k->x+fx))&&
+ (o->y<=(k->y))&&
+ (gInit->mapI.map.tabGif[gInit->mapI.map.tiles*2+k->ID*2+k->data.po->UD+ADD_OBJ]->h+o->y >= (k->y))){
+ o->data.po->cptState=gInit->mapI.map.tabDataSprO[o->ID].state;
+ break;
+ }
+ o=o->next;
+ }
+ }
+ if(err==ccc_oExit){
+ k->ID=9;
+ k->data.pl->cptState=gInit->mapI.lemmingDATA[k->ID].state;
}
- o=o->next;
}
- }
- if(err==ccc_oExit){
- k->ID=9;
- k->data.pl->cptState=gInit->mapI.lemmingDATA[k->ID].state;
- }
+ //-DEBUG-printf("\n");
}
- //-DEBUG-printf("\n");
- }
- k=k->next;
- }// FIN WHILE
-
+ k=k->next;
+ }// FIN WHILE
- return 0;
-}
-int ereasePx(int x,int y,SDL_Surface *s,Uint32 bgColor){
- int err;
- SDL_Rect from,to;
+ return 0;
+ }
- from.x=0;
- from.y=0;
- from.w=s->w;
- from.h=s->h;
+ int ereasePx(int x,int y,SDL_Surface *s,Uint32 bgColor){
+ int err;
+ SDL_Rect from,to;
- to.x=x;
- to.y=y;
- to.w=x+s->w;
- to.h=y+s->h;
+ from.x=0;
+ from.y=0;
+ from.w=s->w;
+ from.h=s->h;
- if((err=paint_manip(s,from,pTerrain,to,bgColor,ccc_lemming,18))!=0){
- return err;
- }
- if((err=paint_manip(s,from,pStencilFixe,to,ccc_bgStencil,ccc_lemming,18))!=0){
- return err;
- }
+ to.x=x;
+ to.y=y;
+ to.w=x+s->w;
+ to.h=y+s->h;
+ if((err=paint_manip(s,from,pTerrain,to,bgColor,ccc_lemming,17,pStencilFixe))!=0){
+ return err;
+ }
+ if((err=paint_manip(s,from,pStencilFixe,to,ccc_bgStencil,ccc_lemming,18,NULL))!=0){
+ return err;
+ }
- return 0;
-}
-int print_num(SDL_Surface *dst, SDL_Surface *src, int x, int y, int value)
-{
- char buf[9];
- int i,r,v,p=0;
- int max = 1000000000;
- SDL_Rect from;
- if(value >= 1000000000){
- //-DEBUG-printf("value out of Bound %d\n",value);
- return(15);
+ return 0;
}
- v=value;
- while(max > 1)
+ int print_num(SDL_Surface *dst, SDL_Surface *src, int x, int y, int value)
{
- r = v / max;
- v -= r * max;
- max /= 10;
- if(p || r)
- buf[p++] = r;
- }
- buf[p++] = value%10;
+ char buf[9];
+ int i,r,v,p=0;
+ int max = 1000000000;
+ SDL_Rect from;
+ if(value >= 1000000000){
+ //-DEBUG-printf("value out of Bound %d\n",value);
+ return(15);
+ }
+ v=value;
- /* Render! */
- from.x = 0;
- from.w = src->w;
- from.h = src->h/10;
+ while(max > 1)
+ {
+ r = v / max;
+ v -= r * max;
+ max /= 10;
+ if(p || r)
+ buf[p++] = r;
+ }
+ buf[p++] = value%10;
- 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);
+ /* Render! */
+ from.x = 0;
+ from.w = src->w;
+ from.h = src->h/10;
+
+ 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);
+ }
+ return 0;
}
- return 0;
-}
-int paint_bomber(int x,int y,int xMax,SDL_Surface *cooldown,SDL_Surface *dst,int cpt){
+ int paint_bomber(int x,int y,int xMax,SDL_Surface *cooldown,SDL_Surface *dst,int cpt){
- SDL_Rect rect,to;
+ SDL_Rect rect,to;
- to.x=x;//+xMax/2;
- rect.x=0;
- rect.h=cooldown->h/5;
- rect.y= rect.h * (cpt-1);
- to.y=y-rect.h;
- rect.w=cooldown->w;
+ to.x=x;//+xMax/2;
+ rect.x=0;
+ rect.h=cooldown->h/5;
+ rect.y= rect.h * (cpt-1);
+ to.y=y-rect.h;
+ rect.w=cooldown->w;
- test_blit(cooldown, &rect, dst, &to);
+ test_blit(cooldown, &rect, dst, &to);
- return 0;
-}
+ return 0;
+ }
-int testAlpha(SDL_Surface *dst, SDL_Surface *src,SDL_Surface *src2, int x, int y){
- SDL_Rect from;
- SDL_Rect to;
- int i;
+ int testAlpha(SDL_Surface *dst, SDL_Surface *src,SDL_Surface *src2, int x, int y){
+ SDL_Rect from;
+ SDL_Rect to;
+ int i;
- from.x = 0;
- from.w = src->w;
- from.h = src->h/188;
+ from.x = 0;
+ from.w = src->w;
+ from.h = src->h/188;
- for(i = 0; i < 188; ++i)
- {
- from.y = i * (from.h ) ;
- to.x = x + (i%40)*16;
- to.y = y + from.h * (i/40);
- test_blit(src, &from, dst, &to);
- //print_num(screen, src2, to.x + 20, to.y, i);
- }
+ for(i = 0; i < 188; ++i)
+ {
+ from.y = i * (from.h ) ;
+ to.x = x + (i%40)*16;
+ to.y = y + from.h * (i/40);
+ test_blit(src, &from, dst, &to);
+ //print_num(screen, src2, to.x + 20, to.y, i);
+ }
- return 0;
+ return 0;
-}
+ }
-int print_alpha(SDL_Surface *dst, SDL_Surface *src, int x, int y, char* msg)
-{
- SDL_Rect from;
- SDL_Rect to;
- int i;
- int n;
+ int print_alpha(SDL_Surface *dst, SDL_Surface *src, int x, int y, char* msg)
+ {
+ SDL_Rect from;
+ SDL_Rect to;
+ int i;
+ int n;
- from.x = 0;
- from.w = src->w;
- from.h = src->h/188;
+ from.x = 0;
+ from.w = src->w;
+ from.h = src->h/188;
- for(i = 0; i < strlen(msg); ++i)
- {
- n=msg[i];
- ////-DEBUG-printf("-> %d ~ %c\n",n,n);
- from.y = 404;
- if (n > 32 && n < 127) { from.y = (n - 33) * (from.h) ;}
- //if (n == 32) {continue;}
- to.x = x + i * (from.w);
- to.y = y;
- if(from.y!=404){
- test_blit(src, &from, dst, &to);
+ for(i = 0; i < strlen(msg); ++i)
+ {
+ n=msg[i];
+ //-DEBUG-printf("-> %d ~ %c\n",n,n);
+ from.y = -1;
+ if (n > 32 && n < 127) { from.y = (n - 33) * (from.h) ;}
+ //if (n == 32) {continue;}
+ to.x = x + i * (from.w);
+ to.y = y;
+ if(from.y!=-1){
+ test_blit(src, &from, dst, &to);
+ }
}
+ return 0;
}
- return 0;
-}
-SDL_Surface* flipSurfaceUD_LR(SDL_Surface* src, enum sens sensO, Uint32 c) {
- int i,j;
-
- SDL_Surface* copy_surface = NULL;
-
- // This only works for 32 bit pixel format
- if( src->format->BitsPerPixel == 32 ) {
- // This surface must be freed by the caller.
- copy_surface = SDL_CreateRGBSurface(src->flags, src->w, src->h,
- src->format->BitsPerPixel,
-
- src->format->Rmask,
- src->format->Gmask,
- src->format->Bmask,
- src->format->Amask);
-
- SDL_SetColorKey( copy_surface,
- SDL_RLEACCEL | SDL_SRCCOLORKEY,
- SDL_MapRGB/*A*/( copy_surface->format,
- (c >> 16) & 0xff,
- (c >> 8) & 0xff,
- (c & 0xff)//,
- //(c >> 24) & 0xff
- )
- );
-
- //FIXME : lock surface
- Uint32 *source = src->pixels;
- Uint32 *dest = copy_surface->pixels;
-
- for(i = 0; i < src->h; i++) {
- for(j = 0; j < src->w; j++) {
- if (sensO == UD){// Sens UD
- dest[ (src->h-i-1)*src->w + j ] = source[ i*src->w + j];
- }
- if (sensO == LR){// Sens LR
- dest[ i*src->w + (src->w-j-1) ] = source[ i*src->w + j];
+ SDL_Surface* flipSurfaceUD_LR(SDL_Surface* src, enum sens sensO, Uint32 c) {
+ int i,j;
+
+ SDL_Surface* copy_surface = NULL;
+
+ // This only works for 32 bit pixel format
+ if( src->format->BitsPerPixel == 32 ) {
+ // This surface must be freed by the caller.
+ copy_surface = SDL_CreateRGBSurface(src->flags, src->w, src->h,
+ src->format->BitsPerPixel,
+
+ src->format->Rmask,
+ src->format->Gmask,
+ src->format->Bmask,
+ src->format->Amask);
+
+ SDL_SetColorKey( copy_surface,
+ SDL_RLEACCEL | SDL_SRCCOLORKEY,
+ //src->format->colorkey
+ SDL_MapRGB( copy_surface->format,
+ (c >> 16) & 0xff,
+ (c >> 8) & 0xff,
+ (c & 0xff))
+ );
+
+ //FIXME : lock surface
+ Uint32 *source = src->pixels;
+ Uint32 *dest = copy_surface->pixels;
+
+ for(i = 0; i < src->h; i++) {
+ for(j = 0; j < src->w; j++) {
+ if (sensO == UD){// Sens UD
+ dest[ (src->h-i-1)*src->w + j ] = source[ i*src->w + j];
+ }
+ if (sensO == LR){// Sens LR
+ dest[ i*src->w + (src->w-j-1) ] = source[ i*src->w + j];
+ }
}
}
}
- }
- return copy_surface;
-}
+ return copy_surface;
+ }
-SDL_Surface *load_image( char* filename, Uint32 cbg )
-{
- //L'image qui est chargée
- SDL_Surface* loadedImage = NULL;
+ SDL_Surface *load_image( char* filename, Uint32 cbg )
+ {
+ //L'image qui est chargée
+ SDL_Surface* loadedImage = NULL;
- //L'image optimisée qu'on va utiliser
- SDL_Surface* optimizedImage = NULL;
+ //L'image optimisée qu'on va utiliser
+ SDL_Surface* optimizedImage = NULL;
- //Chargement de l'image
- loadedImage = IMG_Load( filename );
+ //Chargement de l'image
+ loadedImage = IMG_Load( filename );
- //Si l'image est chargée
- if( loadedImage != NULL )
- {
- //Création de l'image optimisée
- optimizedImage = SDL_DisplayFormat( loadedImage );
+ //Si l'image est chargée
+ if( loadedImage != NULL )
+ {
+ //Création de l'image optimisée
+ optimizedImage = SDL_DisplayFormat( loadedImage );
- //Libération de l'ancienne image
- SDL_FreeSurface( loadedImage );
- //Si la création de l'image optimisée s'est bien passée
- if( optimizedImage != NULL )
- {
- SDL_SetColorKey( optimizedImage,
- SDL_RLEACCEL | SDL_SRCCOLORKEY,
- SDL_MapRGB( optimizedImage->format,
- (cbg >> 16) & 0xff,
- (cbg >> 8) & 0xff,
- (cbg & 0xff)//,
- //(cbg >> 24) & 0xff
- )
- );
+ //Si la création de l'image optimisée s'est bien passée
+ if( optimizedImage != NULL )
+ {
+ SDL_SetColorKey( optimizedImage,
+ SDL_RLEACCEL | SDL_SRCCOLORKEY,
+ SDL_MapRGB( optimizedImage->format,
+ (cbg >> 16) & 0xff,
+ (cbg >> 8) & 0xff,
+ (cbg & 0xff))
+ );
+ }
+ //Libération de l'ancienne image
+ SDL_FreeSurface( loadedImage );
}
- }
- //On retourne l'image optimisée
- return optimizedImage;
+ //On retourne l'image optimisée
+ return optimizedImage;
- return loadedImage;
-}
+ //return loadedImage;
+ }
-int load_fields(char *folder, struct gameInit *gInit, int tabNum[255] ) {
- int i, lt,total,cpt=-1,llem;
- char *temp;
- char *filepath;
- char *folderLem;
+ int load_fields(char *folder, struct gameInit *gInit, int tabNum[255] ) {
+ int i, lt,total,cpt=-1,llem;
+ char *temp;
+ char *filepath;
+ char *folderLem;
- temp = tabString_eMapStyle[gInit->mapI.map.style];
- lt = strlen(temp);
+ temp = tabString_eMapStyle[gInit->mapI.map.style];
+ lt = strlen(temp);
- llem= strlen("../../../misc/");
- folderLem=malloc(sizeof(char)*(llem+1));
- sprintf(folderLem,"%s","../../../misc/");
+ llem= strlen("../../../misc/");
+ folderLem=malloc(sizeof(char)*(llem+1));
+ sprintf(folderLem,"%s","../../../misc/");
- total=(LEM_JOB*2) + (gInit->mapI.map.tiles)*2 + gInit->mapI.map.tilesSteel + ((gInit->mapI.map.tilesObjet)*2);
+ total=(LEM_JOB*2) + (gInit->mapI.map.tiles)*2 + gInit->mapI.map.tilesSteel + ((gInit->mapI.map.tilesObjet)*2);
- gInit->mapI.map.tabGif=malloc((total + ADD_OBJ) * sizeof(SDL_Surface *));
+ gInit->mapI.map.tabGif=malloc((total + ADD_OBJ) * sizeof(SDL_Surface *));
- //stored terrains
- cpt=ADD_OBJ;
+ //stored terrains
+ cpt=ADD_OBJ;
- filepath = malloc(sizeof(char)*(strlen(folder)+lt+strlen("/_.gif")+(sizeof(int)*10)));
+ filepath = malloc(sizeof(char)*(strlen(folder)+lt+strlen("/_.gif")+(sizeof(int)*10)));
- for(i=0; i < gInit->mapI.map.tiles*2 ; i+=2) {
- sprintf(filepath, "%s/%s%s%d.gif", folder,temp,"_", i/2);
- gInit->mapI.map.tabGif[i+cpt] = load_image(filepath,ccc_keyGif);
- gInit->mapI.map.tabGif[i+1+cpt] = flipSurfaceUD_LR(load_image(filepath,ccc_keyGif),UD,ccc_keyGif);
- if((gInit->mapI.map.tabGif[i+cpt] == NULL)||(gInit->mapI.map.tabGif[i+1+cpt] == NULL)) {
- //-DEBUG-printf("ERREUR load_file Objet: %s\n", filepath);
- return(16);
- } else {
- //-DEBUG-printf("load_file ok : %i -> '%s' + flip_LR\n", i+cpt, filepath);
+ for(i=0; i < gInit->mapI.map.tiles*2 ; i+=2) {
+ sprintf(filepath, "%s/%s%s%d.gif", folder,temp,"_", i/2);
+ gInit->mapI.map.tabGif[i+cpt] = load_image(filepath,ccc_keyGif);
+ gInit->mapI.map.tabGif[i+1+cpt] = flipSurfaceUD_LR(load_image(filepath,ccc_keyGif),UD,ccc_keyGif);
+ if((gInit->mapI.map.tabGif[i+cpt] == NULL)||(gInit->mapI.map.tabGif[i+1+cpt] == NULL)) {
+ //-DEBUG-printf("ERREUR load_file Objet: %s\n", filepath);
+ return(16);
+ } else {
+ //-DEBUG-printf("load_file ok : %i -> '%s' + flip_LR\n", i+cpt, filepath);
+ }
+ }
+ free(filepath);
+ //stored objet
+ cpt=ADD_OBJ+gInit->mapI.map.tiles*2;
+
+ filepath = malloc(sizeof(char)*(strlen(folder)+lt+strlen("/o_.gif")+(sizeof(int)*10)));
+
+ for(i=0; i < gInit->mapI.map.tilesObjet*2 ; i+=2) {
+ sprintf(filepath, "%s/%s%s%d.gif", folder,temp,"o_", i/2);
+ gInit->mapI.map.tabGif[i+cpt] = load_image(filepath,ccc_keyGif);
+ gInit->mapI.map.tabGif[i+1+cpt] = flipSurfaceUD_LR(load_image(filepath,ccc_keyGif),UD,ccc_keyGif);
+ if((gInit->mapI.map.tabGif[i+cpt] == NULL)||(gInit->mapI.map.tabGif[i+1+cpt] == NULL)) {
+ //-DEBUG-printf("ERREUR load_file Objet: %s\n", filepath);
+ return(17);
+ } else {
+ //-DEBUG-printf("load_file ok : %i -> '%s' + flip_LR\n", i+cpt, filepath);
+ }
+ }
+ free(filepath);
+ //stored steel
+ cpt=ADD_OBJ+(gInit->mapI.map.tiles*2)+(gInit->mapI.map.tilesObjet*2);
+
+ filepath = malloc(sizeof(char)*(strlen(folder)+lt+strlen("/om_.gif")+(sizeof(int)*10)));
+
+ for(i=0; i < gInit->mapI.map.tilesSteel ; ++i) {
+ sprintf(filepath, "%s/%s%s%d.gif", folder,temp,"om_", tabNum[i]);
+ gInit->mapI.map.tabGif[i+cpt] = load_image(filepath,ccc_keyGif);
+ if(gInit->mapI.map.tabGif[i+cpt] == NULL) {
+ //-DEBUG-printf("ERREUR load_file steel: %s\n", filepath);
+ return(18);
+ } else {
+ //-DEBUG-printf("load_file ok : %i -> '%s'\n", i+cpt, filepath);
+ }
+ }
+ free(filepath);
+ //stored lemmingsDATA
+ cpt=ADD_OBJ+(gInit->mapI.map.tilesObjet*2)+(gInit->mapI.map.tiles)*2+gInit->mapI.map.tilesSteel;
+
+ filepath = malloc(sizeof(char)*(strlen(folderLem)+strlen("lemm")+strlen("/_.gif")+(sizeof(int)*10)));
+
+ for(i=0; i < LEM_JOB*2 ; i+=2) {
+ sprintf(filepath, "%s/%s%d.gif", folderLem,"lemm_",i/2);
+ gInit->mapI.map.tabGif[i+1+cpt] = load_image(filepath,ccc_lemming);
+ gInit->mapI.map.tabGif[i+cpt] = flipSurfaceUD_LR(load_image(filepath,ccc_lemming),LR,ccc_lemming);
+ if((gInit->mapI.map.tabGif[i+cpt] == NULL)||(gInit->mapI.map.tabGif[i+1+cpt] == NULL)) {
+ //-DEBUG-printf("ERREUR load_file lemmingsDATA: %s\n", filepath);
+ return(19);
+ } else {
+ //-DEBUG-printf("load_file ok : %i -> '%s' + flip_LR\n", i+cpt, filepath);
+ }
}
- }
- free(filepath);
- //stored objet
- cpt=ADD_OBJ+gInit->mapI.map.tiles*2;
-
- filepath = malloc(sizeof(char)*(strlen(folder)+lt+strlen("/o_.gif")+(sizeof(int)*10)));
-
- for(i=0; i < gInit->mapI.map.tilesObjet*2 ; i+=2) {
- sprintf(filepath, "%s/%s%s%d.gif", folder,temp,"o_", i/2);
- gInit->mapI.map.tabGif[i+cpt] = load_image(filepath,ccc_keyGif);
- gInit->mapI.map.tabGif[i+1+cpt] = flipSurfaceUD_LR(load_image(filepath,ccc_keyGif),UD,ccc_keyGif);
- if((gInit->mapI.map.tabGif[i+cpt] == NULL)||(gInit->mapI.map.tabGif[i+1+cpt] == NULL)) {
- //-DEBUG-printf("ERREUR load_file Objet: %s\n", filepath);
- return(17);
- } else {
- ////-DEBUG-printf("load_file ok : %i -> '%s' + flip_LR\n", i+cpt, filepath);
+ free(filepath);
+ //0: lemmfont.gif
+ gInit->mapI.map.tabGif[0]= load_image("../../../misc/lemmfont.gif",gInit->mapI.map.cmap.bgColor);
+ if ( gInit->mapI.map.tabGif[0] == NULL ) {
+ //-DEBUG-printf("ERREUR load_file lemmfont.gif: %s\n", "../../../misc/lemmfont.gif");
+ return(20);
}
- }
- free(filepath);
- //stored steel
- cpt=ADD_OBJ+(gInit->mapI.map.tiles*2)+(gInit->mapI.map.tilesObjet*2);
-
- filepath = malloc(sizeof(char)*(strlen(folder)+lt+strlen("/om_.gif")+(sizeof(int)*10)));
-
- for(i=0; i < gInit->mapI.map.tilesSteel ; ++i) {
- sprintf(filepath, "%s/%s%s%d.gif", folder,temp,"om_", tabNum[i]);
- gInit->mapI.map.tabGif[i+cpt] = load_image(filepath,ccc_keyGif);
- if(gInit->mapI.map.tabGif[i+cpt] == NULL) {
- //-DEBUG-printf("ERREUR load_file steel: %s\n", filepath);
- return(18);
- } else {
- ////-DEBUG-printf("load_file ok : %i -> '%s'\n", i+cpt, filepath);
- }
- }
- free(filepath);
- //stored lemmingsDATA
- cpt=ADD_OBJ+(gInit->mapI.map.tilesObjet*2)+(gInit->mapI.map.tiles)*2+gInit->mapI.map.tilesSteel;
-
- filepath = malloc(sizeof(char)*(strlen(folderLem)+strlen("lemm")+strlen("/_.gif")+(sizeof(int)*10)));
-
- for(i=0; i < LEM_JOB*2 ; i+=2) {
- sprintf(filepath, "%s/%s%d.gif", folderLem,"lemm_",i/2);
- gInit->mapI.map.tabGif[i+1+cpt] = load_image(filepath,ccc_lemming);
- gInit->mapI.map.tabGif[i+cpt] = flipSurfaceUD_LR(load_image(filepath,ccc_lemming),LR,ccc_lemming);
- if((gInit->mapI.map.tabGif[i+cpt] == NULL)||(gInit->mapI.map.tabGif[i+1+cpt] == NULL)) {
- //-DEBUG-printf("ERREUR load_file lemmingsDATA: %s\n", filepath);
- return(19);
- } else {
- ////-DEBUG-printf("load_file ok : %i -> '%s' + flip_LR\n", i+cpt, filepath);
+ //1: numfont.gif
+ gInit->mapI.map.tabGif[1]= load_image("../../../misc/numfont.gif",gInit->mapI.map.cmap.bgColor);
+ if ( gInit->mapI.map.tabGif[1] == NULL ) {
+ //-DEBUG-printf("ERREUR load_file numfont.gif: %s\n", "../../../misc/numfont.gif");
+ return(21);
}
- }
- free(filepath);
- //0: lemmfont.gif
- gInit->mapI.map.tabGif[0]= load_image("../../../misc/lemmfont.gif",gInit->mapI.map.cmap.bgColor);
- if ( gInit->mapI.map.tabGif[0] == NULL ) {
- //-DEBUG-printf("ERREUR load_file lemmfont.gif: %s\n", "../../../misc/lemmfont.gif");
- return(20);
- }
- //1: numfont.gif
- gInit->mapI.map.tabGif[1]= load_image("../../../misc/numfont.gif",gInit->mapI.map.cmap.bgColor);
- if ( gInit->mapI.map.tabGif[1] == NULL ) {
- //-DEBUG-printf("ERREUR load_file numfont.gif: %s\n", "../../../misc/numfont.gif");
- return(21);
- }
- //2: countdown.gif
- gInit->mapI.map.tabGif[2]= load_image("../../../misc/countdown.gif",ccc_lemming);
- if ( gInit->mapI.map.tabGif[2] == NULL ) {
- //-DEBUG-printf("ERREUR load_file countdown.gif: %s\n", "../../../misc/countdown.gif");
- return(22);
- }
- //3: cursor.gif
- gInit->mapI.map.tabGif[3]= load_image("../../../misc/cursor.gif",ccc_cursor);//gInit->mapI.map.cmap.bgColor);
- if ( gInit->mapI.map.tabGif[3] == NULL ) {
- //-DEBUG-printf("ERREUR load_file cursor.gif: %s\n", "../../../misc/cursor.gif");
- return(23);
- }
- //4: explode.gif
- gInit->mapI.map.tabGif[4]= load_image("../../../misc/explode.gif",gInit->mapI.map.cmap.bgColor);
- if ( gInit->mapI.map.tabGif[4] == NULL ) {
- //-DEBUG-printf("ERREUR load_file explode.gif: %s\n", "../../../misc/explode.gif");
- return(24);
- }
- //5: border.gif
- gInit->mapI.map.tabGif[5]= load_image("../../../misc/border.gif",gInit->mapI.map.cmap.bgColor);
- if ( gInit->mapI.map.tabGif[5] == NULL ) {
- //-DEBUG-printf("ERREUR load_file border.gif: %s\n", "../../../misc/border.gif");
- return(25);
- }
- //6: replay.gif
- gInit->mapI.map.tabGif[6]= load_image("../../../misc/replay.gif",gInit->mapI.map.cmap.bgColor);
- if ( gInit->mapI.map.tabGif[6] == NULL ) {
- //-DEBUG-printf("ERREUR load_file replay.gif: %s\n", "../../../misc/replay.gif");
- return(26);
- }
- //7: select.gif
- gInit->mapI.map.tabGif[7]= load_image("../../../misc/select.gif",gInit->mapI.map.cmap.bgColor);
- if ( gInit->mapI.map.tabGif[7] == NULL ) {
- //-DEBUG-printf("ERREUR load_file select.gif: %s\n", "../../../misc/select.gif");
- return(27);
- }
- // 8: font7x10.bmp
- gInit->mapI.map.tabGif[8]= load_image("./font7x10.bmp",gInit->mapI.map.cmap.bgColor);
- if ( gInit->mapI.map.tabGif[8] == NULL ) {
- //-DEBUG-printf("ERREUR load_file font7x10.bmp: %s\n", "./font7x10.bmp");
- return(28);
- }
- // 9: alphabet.gif
- gInit->mapI.map.tabGif[9]= load_image("./alphabet.gif",ccc_cursor);
- if ( gInit->mapI.map.tabGif[9] == NULL ) {
- //-DEBUG-printf("ERREUR load_file alphabet.gif: %s\n", "./alphabet.gif");
- return(29);
- }
- //10: mask_10.gif
- gInit->mapI.map.tabGif[10]= load_image("../../../misc/mask_10.gif",ccc_cursor);
- if ( gInit->mapI.map.tabGif[10] == NULL ) {
- //-DEBUG-printf("ERREUR load_file mask_10.gif: %s\n", "../../../misc/mask_10.gif");
- return(30);
- }
- //11: mask_11.gif
- gInit->mapI.map.tabGif[11]= load_image("../../../misc/mask_11.gif",ccc_cursor);
- if ( gInit->mapI.map.tabGif[11] == NULL ) {
- //-DEBUG-printf("ERREUR load_file mask_11.gif: %s\n", "../../../misc/mask_11.gif");
- return(31);
- }
- //12: mask_6.gif
- gInit->mapI.map.tabGif[12]= load_image("../../../misc/mask_6.gif",ccc_cursor);
- if ( gInit->mapI.map.tabGif[12] == NULL ) {
- //-DEBUG-printf("ERREUR load_file mask_6.gif: %s\n", "../../../misc/mask_6.gif");
- return(32);
- }
- //13: mask_13.gif
- gInit->mapI.map.tabGif[13]= load_image("../../../misc/mask_13.gif",ccc_cursor);
- if ( gInit->mapI.map.tabGif[13] == NULL ) {
- //-DEBUG-printf("ERREUR load_file mask_13.gif: %s\n", "../../../misc/mask_13.gif");
- return(33);
- }
- //14: mask_14.gif
- gInit->mapI.map.tabGif[14]= load_image("../../../misc/mask_14.gif",ccc_cursor);
- if ( gInit->mapI.map.tabGif[14] == NULL ) {
- //-DEBUG-printf("ERREUR load_file mask_14.gif: %s\n", "../../../misc/mask_14.gif");
- return(34);
- }
- //15: mask_15.gif
- gInit->mapI.map.tabGif[15]= load_image("../../../misc/mask_15.gif",ccc_cursor);
- if ( gInit->mapI.map.tabGif[15] == NULL ) {
- //-DEBUG-printf("ERREUR load_file mask_15.gif: %s\n", "../../../misc/mask_15.gif");
- return(35);
- }
- //16: imask_13.gif
- gInit->mapI.map.tabGif[16]= load_image("../../../misc/imask_13.gif",ccc_cursor);
- if ( gInit->mapI.map.tabGif[16] == NULL ) {
- //-DEBUG-printf("ERREUR load_file imask_13.gif: %s\n", "../../../misc/imask_13.gif");
- return(36);
- }
- //17: imask_14.gif
- gInit->mapI.map.tabGif[17]= load_image("../../../misc/imask_14.gif",ccc_cursor);
- if ( gInit->mapI.map.tabGif[17] == NULL ) {
- //-DEBUG-printf("ERREUR load_file imask_14.gif: %s\n", "../../../misc/imask_14.gif");
- return(37);
- }
- //18: imask_15.gif
- gInit->mapI.map.tabGif[18]= load_image("../../../misc/imask_15.gif",ccc_cursor);
- if ( gInit->mapI.map.tabGif[18] == NULL ) {
- //-DEBUG-printf("ERREUR load_file imask_15.gif: %s\n", "../../../misc/imask_15.gif");
- return(38);
- }
-
- //icone.gif
- cpt=NBR_ADD_OBJ;
- filepath = malloc(sizeof(char)*(strlen(folderLem)+strlen("icon")+strlen("/__alt.gif")+(sizeof(int)*10)));
-
- for(i=0; i < NBR_BUTTON_LEMMING ; ++i) {
- sprintf(filepath, "%s/%s%d.gif", folderLem,"icon_",i);
- //if(i<7){sprintf(filepath, "%s/%s%d.gif", folderLem,"icon_",i);}
- //if(i==7){sprintf(filepath, "%s/%s.gif", folderLem,"icon_6_alt");}
- //if(i>7){sprintf(filepath, "%s/%s%d.gif", folderLem,"icon_",i-1);}
- gInit->mapI.map.tabGif[i+cpt] = load_image(filepath,ccc_black);
- if(gInit->mapI.map.tabGif[i+cpt] == NULL) {
- //-DEBUG-printf("ERREUR load_file icon: %s\n", filepath);
+ //2: countdown.gif
+ gInit->mapI.map.tabGif[2]= load_image("../../../misc/countdown.gif",ccc_lemming);
+ if ( gInit->mapI.map.tabGif[2] == NULL ) {
+ //-DEBUG-printf("ERREUR load_file countdown.gif: %s\n", "../../../misc/countdown.gif");
+ return(22);
+ }
+ //3: cursor.gif
+ gInit->mapI.map.tabGif[3]= load_image("../../../misc/cursor.gif",ccc_cursor);//gInit->mapI.map.cmap.bgColor);
+ if ( gInit->mapI.map.tabGif[3] == NULL ) {
+ //-DEBUG-printf("ERREUR load_file cursor.gif: %s\n", "../../../misc/cursor.gif");
+ return(23);
+ }
+ //4: explode.gif
+ gInit->mapI.map.tabGif[4]= load_image("../../../misc/explode.gif",gInit->mapI.map.cmap.bgColor);
+ if ( gInit->mapI.map.tabGif[4] == NULL ) {
+ //-DEBUG-printf("ERREUR load_file explode.gif: %s\n", "../../../misc/explode.gif");
+ return(24);
+ }
+ //5: border.gif
+ gInit->mapI.map.tabGif[5]= load_image("../../../misc/border.gif",gInit->mapI.map.cmap.bgColor);
+ if ( gInit->mapI.map.tabGif[5] == NULL ) {
+ //-DEBUG-printf("ERREUR load_file border.gif: %s\n", "../../../misc/border.gif");
+ return(25);
+ }
+ //6: replay.gif
+ gInit->mapI.map.tabGif[6]= load_image("../../../misc/replay.gif",gInit->mapI.map.cmap.bgColor);
+ if ( gInit->mapI.map.tabGif[6] == NULL ) {
+ //-DEBUG-printf("ERREUR load_file replay.gif: %s\n", "../../../misc/replay.gif");
+ return(26);
+ }
+ //7: select.gif
+ gInit->mapI.map.tabGif[7]= load_image("../../../misc/select.gif",gInit->mapI.map.cmap.bgColor);
+ if ( gInit->mapI.map.tabGif[7] == NULL ) {
+ //-DEBUG-printf("ERREUR load_file select.gif: %s\n", "../../../misc/select.gif");
+ return(27);
+ }
+ // 8: font7x10.bmp
+ gInit->mapI.map.tabGif[8]= load_image("./font7x10.bmp",gInit->mapI.map.cmap.bgColor);
+ if ( gInit->mapI.map.tabGif[8] == NULL ) {
+ //-DEBUG-printf("ERREUR load_file font7x10.bmp: %s\n", "./font7x10.bmp");
+ return(28);
+ }
+ // 9: alphabet.gif
+ gInit->mapI.map.tabGif[9]= load_image("./alphabet.gif",ccc_cursor);
+ if ( gInit->mapI.map.tabGif[9] == NULL ) {
+ //-DEBUG-printf("ERREUR load_file alphabet.gif: %s\n", "./alphabet.gif");
+ return(29);
+ }
+ //10: mask_10.gif
+ gInit->mapI.map.tabGif[10]= load_image("../../../misc/mask_10.gif",ccc_cursor);
+ if ( gInit->mapI.map.tabGif[10] == NULL ) {
+ //-DEBUG-printf("ERREUR load_file mask_10.gif: %s\n", "../../../misc/mask_10.gif");
+ return(30);
+ }
+ //11: mask_11.gif
+ gInit->mapI.map.tabGif[11]= load_image("../../../misc/mask_11.gif",ccc_cursor);
+ if ( gInit->mapI.map.tabGif[11] == NULL ) {
+ //-DEBUG-printf("ERREUR load_file mask_11.gif: %s\n", "../../../misc/mask_11.gif");
return(31);
- } else {
- ////-DEBUG-printf("load_file ok : %i -> '%s' + flip_LR\n", i+cpt, filepath);
}
- }
- free(filepath);
- free(folderLem);
-
- return 0;
-}
+ //12: mask_6.gif
+ gInit->mapI.map.tabGif[12]= load_image("../../../misc/mask_6.gif",ccc_cursor);
+ if ( gInit->mapI.map.tabGif[12] == NULL ) {
+ //-DEBUG-printf("ERREUR load_file mask_6.gif: %s\n", "../../../misc/mask_6.gif");
+ return(32);
+ }
+ //13: mask_13.gif
+ gInit->mapI.map.tabGif[13]= load_image("../../../misc/mask_13.gif",ccc_cursor);
+ if ( gInit->mapI.map.tabGif[13] == NULL ) {
+ //-DEBUG-printf("ERREUR load_file mask_13.gif: %s\n", "../../../misc/mask_13.gif");
+ return(33);
+ }
+ //14: mask_14.gif
+ gInit->mapI.map.tabGif[14]= load_image("../../../misc/mask_14.gif",ccc_cursor);
+ if ( gInit->mapI.map.tabGif[14] == NULL ) {
+ //-DEBUG-printf("ERREUR load_file mask_14.gif: %s\n", "../../../misc/mask_14.gif");
+ return(34);
+ }
+ //15: mask_15.gif
+ gInit->mapI.map.tabGif[15]= load_image("../../../misc/mask_15.gif",ccc_cursor);
+ if ( gInit->mapI.map.tabGif[15] == NULL ) {
+ //-DEBUG-printf("ERREUR load_file mask_15.gif: %s\n", "../../../misc/mask_15.gif");
+ return(35);
+ }
+ //16: imask_13.gif
+ gInit->mapI.map.tabGif[16]= load_image("../../../misc/imask_13.gif",ccc_cursor);
+ if ( gInit->mapI.map.tabGif[16] == NULL ) {
+ //-DEBUG-printf("ERREUR load_file imask_13.gif: %s\n", "../../../misc/imask_13.gif");
+ return(36);
+ }
+ //17: imask_14.gif
+ gInit->mapI.map.tabGif[17]= load_image("../../../misc/imask_14.gif",ccc_cursor);
+ if ( gInit->mapI.map.tabGif[17] == NULL ) {
+ //-DEBUG-printf("ERREUR load_file imask_14.gif: %s\n", "../../../misc/imask_14.gif");
+ return(37);
+ }
+ //18: imask_15.gif
+ gInit->mapI.map.tabGif[18]= load_image("../../../misc/imask_15.gif",ccc_cursor);
+ if ( gInit->mapI.map.tabGif[18] == NULL ) {
+ //-DEBUG-printf("ERREUR load_file imask_15.gif: %s\n", "../../../misc/imask_15.gif");
+ return(38);
+ }
+ //icone.gif
+ cpt=NBR_ADD_OBJ;
+ filepath = malloc(sizeof(char)*(strlen(folderLem)+strlen("icon")+strlen("/__alt.gif")+(sizeof(int)*10)));
+
+ for(i=0; i < NBR_BUTTON_LEMMING ; ++i) {
+ sprintf(filepath, "%s/%s%d.gif", folderLem,"icon_",i);
+ //if(i<7){sprintf(filepath, "%s/%s%d.gif", folderLem,"icon_",i);}
+ //if(i==7){sprintf(filepath, "%s/%s.gif", folderLem,"icon_6_alt");}
+ //if(i>7){sprintf(filepath, "%s/%s%d.gif", folderLem,"icon_",i-1);}
+ gInit->mapI.map.tabGif[i+cpt] = load_image(filepath,ccc_black);
+ if(gInit->mapI.map.tabGif[i+cpt] == NULL) {
+ //-DEBUG-printf("ERREUR load_file icon: %s\n", filepath);
+ return(31);
+ } else {
+ //-DEBUG-printf("load_file ok : %i -> '%s' + flip_LR\n", i+cpt, filepath);
+ }
+ }
+ free(filepath);
+ free(folderLem);
-int load_files(struct gameInit *gInit)
-{
- int lt,ltt,ltlem;
- int err=0;
- int res, lterrain, lobjet, lsteel;
- char *folder;
- char *spriteINI;
- char *lemINI;
- char *terrainGif;
- char *objetGif;
- char *steelGif;
- char *temp;
- int tabNum[255];
- struct dirent *lecture;
- DIR *rep;
-
- yyparse(gInit);
-
- fclose(yyin);
- //-DEBUG-printf("CLOSE 1\n");
-
-
- lt = (strlen("../../../styles/"));
- ltlem = (strlen("../../../misc/lemming.ini"));
- ltt = (strlen(tabString_eMapStyle[gInit->mapI.map.style]));
-
- folder = malloc(sizeof(char)*(lt+ltt+1));
- spriteINI = malloc(sizeof(char)*(lt+ltt*2+5));// *2:dossier/fichier, +4: .ini, +1: string
- lemINI = malloc(sizeof(char)*ltlem+1);
-
-
- //folder = "/home/jazzblue/Bureau/Projet-Lemmings/trunk/styles/dirt";
- ////-DEBUG-printf("test segFault\n");
- sprintf(folder,"../../../styles/%s",tabString_eMapStyle[gInit->mapI.map.style]);
- sprintf(spriteINI,"%s/%s.ini",folder,tabString_eMapStyle[gInit->mapI.map.style]);
- sprintf(lemINI,"%s","../../../misc/lemming.ini");
- ////-DEBUG-printf("test2\n");
-
- temp = tabString_eMapStyle[gInit->mapI.map.style];
- lt = strlen(temp);
- lterrain = lt+1;
- lobjet = lt+2;
- lsteel = lt+3;
- terrainGif=malloc(sizeof(char)*(lterrain+1));
- objetGif=malloc(sizeof(char)*(lobjet+1));
- steelGif=malloc(sizeof(char)*(lsteel+1));
- sprintf(terrainGif,"%s_",temp);
- sprintf(objetGif,"%so_",temp);
- sprintf(steelGif,"%som_",temp);
-
- // Compter les textures de terrain
- rep = opendir(folder);
- if (rep==NULL) {
- //-DEBUG-printf("Erreur opendir('%s')\n", folder);
- return(31);
+ return 0;
}
- while ((lecture = readdir(rep))) {
- if( (res=strncmp(terrainGif, lecture->d_name,lterrain)) == 0 ){
- ++(gInit->mapI.map.tiles);
- } else {
- if( (res=strncmp(objetGif, lecture->d_name,lobjet)) == 0 ) {
- ++(gInit->mapI.map.tilesObjet);
- } else {
- if ( (res=strncmp(steelGif, lecture->d_name,lsteel)) == 0 ) {
- sscanf(lecture->d_name+lsteel, "%i", &(tabNum[gInit->mapI.map.tilesSteel]));
- ++(gInit->mapI.map.tilesSteel);
+ int load_files(struct gameInit *gInit)
+ {
+ int lt,ltt,ltlem;
+ int err=0;
+ int res, lterrain, lobjet, lsteel;
+ char *folder;
+ char *spriteINI;
+ char *lemINI;
+ char *terrainGif;
+ char *objetGif;
+ char *steelGif;
+ char *temp;
+ int tabNum[255];
+ struct dirent *lecture;
+ DIR *rep;
+
+ yyparse(gInit);
+
+ fclose(yyin);
+ //-DEBUG-printf("CLOSE 1\n");
+
+
+ lt = (strlen("../../../styles/"));
+ ltlem = (strlen("../../../misc/lemming.ini"));
+ ltt = (strlen(tabString_eMapStyle[gInit->mapI.map.style]));
+
+ folder = malloc(sizeof(char)*(lt+ltt+1));
+ spriteINI = malloc(sizeof(char)*(lt+ltt*2+5));// *2:dossier/fichier, +4: .ini, +1: string
+ lemINI = malloc(sizeof(char)*ltlem+1);
+
+
+ //folder = "/home/jazzblue/Bureau/Projet-Lemmings/trunk/styles/dirt";
+ //-DEBUG-printf("test segFault\n");
+ sprintf(folder,"../../../styles/%s",tabString_eMapStyle[gInit->mapI.map.style]);
+ sprintf(spriteINI,"%s/%s.ini",folder,tabString_eMapStyle[gInit->mapI.map.style]);
+ sprintf(lemINI,"%s","../../../misc/lemming.ini");
+ //-DEBUG-printf("test2\n");
+
+ temp = tabString_eMapStyle[gInit->mapI.map.style];
+ lt = strlen(temp);
+ lterrain = lt+1;
+ lobjet = lt+2;
+ lsteel = lt+3;
+ terrainGif=malloc(sizeof(char)*(lterrain+1));
+ objetGif=malloc(sizeof(char)*(lobjet+1));
+ steelGif=malloc(sizeof(char)*(lsteel+1));
+ sprintf(terrainGif,"%s_",temp);
+ sprintf(objetGif,"%so_",temp);
+ sprintf(steelGif,"%som_",temp);
+
+ // Compter les textures de terrain
+ rep = opendir(folder);
+ if (rep==NULL) {
+ //-DEBUG-printf("Erreur opendir('%s')\n", folder);
+ return(31);
+ }
+
+ while ((lecture = readdir(rep))) {
+ if( (res=strncmp(terrainGif, lecture->d_name,lterrain)) == 0 ){
+ ++(gInit->mapI.map.tiles);
+ } else {
+ if( (res=strncmp(objetGif, lecture->d_name,lobjet)) == 0 ) {
+ ++(gInit->mapI.map.tilesObjet);
} else {
- //-DEBUG-printf("BUG : type de fichier non reconnu [%s] \n", lecture->d_name);
+ if ( (res=strncmp(steelGif, lecture->d_name,lsteel)) == 0 ) {
+ sscanf(lecture->d_name+lsteel, "%i", &(tabNum[gInit->mapI.map.tilesSteel]));
+ ++(gInit->mapI.map.tilesSteel);
+
+ } else {
+ //-DEBUG-printf("BUG : type de fichier non reconnu [%s] \n", lecture->d_name);
+ }
}
}
}
- }
- closedir(rep);
-
-
+ closedir(rep);
- yyin=fopen(spriteINI, "r");
- if (yyin==NULL) { fprintf(stderr,"Filename INVALIDE: %s\n",spriteINI);
- perror("Impossible d'ouvrir le fichier de configuration des sprite"); return(32);
- }
- yyparse(gInit);
- fclose(yyin);
- //-DEBUG-printf("CLOSE 2\n");
-
- yyin=fopen(lemINI, "r");
- if (yyin==NULL) { fprintf(stderr,"Filename INVALIDE: %s\n",lemINI);
- perror("Impossible d'ouvrir le fichier de configuration des lemmings"); return(33);
- }
- yyparse(gInit);
- fclose(yyin);
- //-DEBUG-printf("CLOSE 3\n");
- err=load_fields(folder, gInit, tabNum);
- if(err!=0){return err;}
- ////-DEBUG-printf("REVERSE t.lt\n");
- gInit->t.lt=(struct listeSimplementChainee*)rev_listeO(gInit->t.lt);
- ////-DEBUG-printf("REVERSE o.lo\n");
- gInit->o.lo=(struct listeSimplementChainee*)rev_listeO(gInit->o.lo);
- ////-DEBUG-printf("REVERSE s.ls\n");
- gInit->s.ls=(struct listeSimplementChainee*)rev_listeO(gInit->s.ls);
+ yyin=fopen(spriteINI, "r");
+ if (yyin==NULL) { fprintf(stderr,"Filename INVALIDE: %s\n",spriteINI);
+ perror("Impossible d'ouvrir le fichier de configuration des sprite"); return(32);
+ }
+ yyparse(gInit);
+ fclose(yyin);
+ //-DEBUG-printf("CLOSE 2\n");
- // AFFICHAGE DES INFOS DE LA MAP
- err=afficher(gInit);
- if(err!=0){return err;}
+ yyin=fopen(lemINI, "r");
+ if (yyin==NULL) { fprintf(stderr,"Filename INVALIDE: %s\n",lemINI);
+ perror("Impossible d'ouvrir le fichier de configuration des lemmings"); return(33);
+ }
+ yyparse(gInit);
+ fclose(yyin);
+ //-DEBUG-printf("CLOSE 3\n");
- //Si tout s'est bien passé
- free(terrainGif);
- free(objetGif);
- free(steelGif);
- free(folder);
- free(spriteINI);
- free(lemINI);
+ err=load_fields(folder, gInit, tabNum);
+ if(err!=0){return err;}
- return 0;
-}
+ //-DEBUG-printf("REVERSE t.lt\n");
+ gInit->t.lt=(struct listeSimplementChainee*)rev_listeO(gInit->t.lt);
+ //-DEBUG-printf("REVERSE o.lo\n");
+ gInit->o.lo=(struct listeSimplementChainee*)rev_listeO(gInit->o.lo);
+ //-DEBUG-printf("REVERSE s.ls\n");
+ gInit->s.ls=(struct listeSimplementChainee*)rev_listeO(gInit->s.ls);
-int afficher(struct gameInit *gInit){
+ // AFFICHAGE DES INFOS DE LA MAP
+ err=afficher(gInit);
+ if(err!=0){return err;}
- int i;
- struct listeSimplementChainee *k;
+ //Si tout s'est bien passé
+ free(terrainGif);
+ free(objetGif);
+ free(steelGif);
+ free(folder);
+ free(spriteINI);
+ free(lemINI);
- printf("AFFICHAGE DE GAME INIT\n");
- printf("LES PARAMETRES:\n");
- for(i=0;i<IDENT_COUNT;++i){
- printf("\t%s = %d\n",tabString_eParaMap[i],gInit->mapI.paraMap[i]);
+ return 0;
}
- printf("\txPos = %d\n",gInit->mapI.xPos);
- printf("\tstyle = %s\n",tabString_eMapStyle[gInit->mapI.map.style]);
-
- printf("LE NOM DU NIVEAU:\n");
- printf("name = %s\n",gInit->mapI.name);
- printf("LES COULEURS DU NIVEAU:\n");
- printf("bgColor R = %X G = %X B = %X\n",
- ((gInit->mapI.map.cmap.bgColor>>16) & 0xff),
- ((gInit->mapI.map.cmap.bgColor>>8) & 0xff),
- (gInit->mapI.map.cmap.bgColor & 0xff) );
- printf("debrisColor R = %X G = %X B = %X\n",
- ((gInit->mapI.map.cmap.debrisColor>>16) & 0xff),
- ((gInit->mapI.map.cmap.debrisColor>>8) & 0xff),
- (gInit->mapI.map.cmap.debrisColor & 0xff) );
- printf("debrisColor:\n");
- for(i=0;i<PARTICULE_COUNT;++i){
- printf("\tP%d: R = %X G = %X B = %X\n",i,
- ((gInit->mapI.map.cmap.particleColor[i]>>16) & 0xff),
- ((gInit->mapI.map.cmap.particleColor[i]>>8) & 0xff),
- (gInit->mapI.map.cmap.particleColor[i] & 0xff) );
- }
+ int afficher(struct gameInit *gInit){
- printf("TERRAINS:\n");
- k=gInit->t.lt;
- i=0;
- while ( k !=NULL ) {
- if(k->data.pt != NULL){//{printf("paraTerrain non initialiser\n");return(34);}
- printf("\tterrain_%d = %d, %d, %d, %d\n",i,k->ID, k->x, k->y,k->data.pt->modif);
+ int i;
+ struct listeSimplementChainee *k;
+
+ printf("AFFICHAGE DE GAME INIT\n");
+ printf("LES PARAMETRES:\n");
+ for(i=0;i<IDENT_COUNT;++i){
+ printf("\t%s = %d\n",tabString_eParaMap[i],gInit->mapI.paraMap[i]);
}
- ++i;
- k=k->next;
- }
+ printf("\txPos = %d\n",gInit->mapI.xPos);
+ printf("\tstyle = %s\n",tabString_eMapStyle[gInit->mapI.map.style]);
+
+ printf("LE NOM DU NIVEAU:\n");
+ printf("name = %s\n",gInit->mapI.name);
+ printf("LES COULEURS DU NIVEAU:\n");
+ printf("bgColor R = %X G = %X B = %X\n",
+ ((gInit->mapI.map.cmap.bgColor>>16) & 0xff),
+ ((gInit->mapI.map.cmap.bgColor>>8) & 0xff),
+ (gInit->mapI.map.cmap.bgColor & 0xff) );
+ printf("debrisColor R = %X G = %X B = %X\n",
+ ((gInit->mapI.map.cmap.debrisColor>>16) & 0xff),
+ ((gInit->mapI.map.cmap.debrisColor>>8) & 0xff),
+ (gInit->mapI.map.cmap.debrisColor & 0xff) );
+ printf("debrisColor:\n");
+ for(i=0;i<PARTICULE_COUNT;++i){
+ printf("\tP%d: R = %X G = %X B = %X\n",i,
+ ((gInit->mapI.map.cmap.particleColor[i]>>16) & 0xff),
+ ((gInit->mapI.map.cmap.particleColor[i]>>8) & 0xff),
+ (gInit->mapI.map.cmap.particleColor[i] & 0xff) );
- printf("OBJETS:\n");
+ }
- k=gInit->o.lo;
- i=0;
- while ( k !=NULL ) {
- if(k->data.po != NULL){ //{printf("paraObjet non initialiser\n");return(35);}
- printf("\tobject_%d = %d, %d, %d, %d, %d\n",i,k->ID, k->x, k->y, k->data.po->paintMode,k->data.po->UD);
+ printf("TERRAINS:\n");
+ k=gInit->t.lt;
+ i=0;
+ while ( k !=NULL ) {
+ if(k->data.pt != NULL){//{printf("paraTerrain non initialiser\n");return(34);}
+ printf("\tterrain_%d = %d, %d, %d, %d\n",i,k->ID, k->x, k->y,k->data.pt->modif);
+ }
+ ++i;
+ k=k->next;
}
- ++i;
- k=k->next;
- }
+ printf("OBJETS:\n");
- printf("STEELS:\n");
- k=gInit->s.ls;
- i=0;
- while ( k !=NULL ) {
- if(k->data.ps != NULL){//{printf("paraSteel non initialiser\n");return(36);}
- printf("\tsteel_%d = %d, %d, %d, %d, %d\n",i,k->ID=i, k->x, k->y, k->data.ps->w,k->data.ps->h); // FIXME big fuck here with "="
+ k=gInit->o.lo;
+ i=0;
+ while ( k !=NULL ) {
+ if(k->data.po != NULL){ //{printf("paraObjet non initialiser\n");return(35);}
+ printf("\tobject_%d = %d, %d, %d, %d, %d\n",i,k->ID, k->x, k->y, k->data.po->paintMode,k->data.po->UD);
+ }
+ ++i;
+ k=k->next;
}
- ++i;
- k=k->next;
- }
-
- printf("DATA SPRITES OBJET:\n");
- for(i=0;i<gInit->mapI.map.tilesObjet;++i){
- printf("spr_%d:\n\tframes_%d = %d\n\tanim_%d = %d\n\ttype_%d = %d\n\tsound_%d = %d\n",i,i,gInit->mapI.map.tabDataSprO[i].state,i,gInit->mapI.map.tabDataSprO[i].anim,i,gInit->mapI.map.tabDataSprO[i].type,i,gInit->mapI.map.tabDataSprO[i].sound);
- }
- printf("DATA JOB LEMMINGS:\n");
- for(i=0;i<LEM_JOB;++i){
- printf("lem_%d:\n\tlemm_%d = %d, %d, %d\n\tpos_%d = %d, %d, %d\n",i,i,gInit->mapI.lemmingDATA[i].state,gInit->mapI.lemmingDATA[i].dir,gInit->mapI.lemmingDATA[i].anim,i,gInit->mapI.lemmingDATA[i].footX,gInit->mapI.lemmingDATA[i].footY,gInit->mapI.lemmingDATA[i].footSize);
- if (gInit->mapI.lemmingDATA[i].mask != NULL){
- printf("\tmask_%d = %d, %d, %d\n",i,gInit->mapI.lemmingDATA[i].mask->stateM,gInit->mapI.lemmingDATA[i].mask->dirM,gInit->mapI.lemmingDATA[i].mask->cooldown);
+ printf("STEELS:\n");
+ k=gInit->s.ls;
+ i=0;
+ while ( k !=NULL ) {
+ if(k->data.ps != NULL){//{printf("paraSteel non initialiser\n");return(36);}
+ printf("\tsteel_%d = %d, %d, %d, %d, %d\n",i,k->ID=i, k->x, k->y, k->data.ps->w,k->data.ps->h); // FIXME big fuck here with "="
+ }
+ ++i;
+ k=k->next;
}
- if (gInit->mapI.lemmingDATA[i].imask != NULL){
- printf("\timask_%d = %d , %d\n",i,gInit->mapI.lemmingDATA[i].imask->stateI,gInit->mapI.lemmingDATA[i].imask->dirI);
+ printf("DATA SPRITES OBJET:\n");
+ for(i=0;i<gInit->mapI.map.tilesObjet;++i){
+ printf("spr_%d:\n\tframes_%d = %d\n\tanim_%d = %d\n\ttype_%d = %d\n\tsound_%d = %d\n",i,i,gInit->mapI.map.tabDataSprO[i].state,i,gInit->mapI.map.tabDataSprO[i].anim,i,gInit->mapI.map.tabDataSprO[i].type,i,gInit->mapI.map.tabDataSprO[i].sound);
}
- }
- return 0;
-}
-
-int clean_up()
-{
- //On libère la feuille de sprites
- // SDL_FreeSurface( faces );
- SDL_FreeSurface( pTerrain );
- //On quitte SDL
- SDL_Quit();
-
- return 0;
-}
-int initGame(struct gameInit *gInit){
+ printf("DATA JOB LEMMINGS:\n");
+ for(i=0;i<LEM_JOB;++i){
+ printf("lem_%d:\n\tlemm_%d = %d, %d, %d\n\tpos_%d = %d, %d, %d\n",i,i,gInit->mapI.lemmingDATA[i].state,gInit->mapI.lemmingDATA[i].dir,gInit->mapI.lemmingDATA[i].anim,i,gInit->mapI.lemmingDATA[i].footX,gInit->mapI.lemmingDATA[i].footY,gInit->mapI.lemmingDATA[i].footSize);
- int i;
-
- // init liste
- gInit->t.nbr=0;
- gInit->o.nbr=0;
- gInit->s.nbr=0;
- gInit->l.nbrInput=0;
- gInit->l.nbr=0;
- gInit->l.nbrDied=0;
- gInit->l.nbrSafe=0;
-
- gInit->t.lt=NULL;
- gInit->o.lo=NULL;
- gInit->s.ls=NULL;
- gInit->l.ll=NULL;
+ if (gInit->mapI.lemmingDATA[i].mask != NULL){
+ printf("\tmask_%d = %d, %d, %d\n",i,gInit->mapI.lemmingDATA[i].mask->stateM,gInit->mapI.lemmingDATA[i].mask->dirM,gInit->mapI.lemmingDATA[i].mask->cooldown);
+ }
- // init button state
- for(i=0;i<NBR_CPT;++i){
- gInit->cptGame[i]=0;
+ if (gInit->mapI.lemmingDATA[i].imask != NULL){
+ printf("\timask_%d = %d , %d\n",i,gInit->mapI.lemmingDATA[i].imask->stateI,gInit->mapI.lemmingDATA[i].imask->dirI);
+ }
+ }
+ return 0;
}
- gInit->cptGame[17]=404;
- // init InfoMap
- // map name
- gInit->mapI.name = NULL;
+ int clean_up()
+ {
+ //On libère la feuille de sprites
+ // SDL_FreeSurface( faces );
+ SDL_FreeSurface( pTerrain );
+ //On quitte SDL
+ SDL_Quit();
- // paraMap
- for(i=0;i<IDENT_COUNT;++i){
- gInit->mapI.paraMap[i]=0;
+ return 0;
}
- // xPos
- gInit->mapI.xPos=0;
-
- //MaxFallDistance
- gInit->mapI.nbrEntry=0;
- gInit->mapI.MaxFallDistance = 126;
- gInit->mapI.nuke=0;
-
- // init MapStyle
- gInit->mapI.map.style=undefined;
- gInit->mapI.map.superLemming=0;
- gInit->mapI.map.tiles=0;
- gInit->mapI.map.tilesObjet=0;
- gInit->mapI.map.tilesSteel=0;
- gInit->mapI.map.tabDataSprO=NULL;
- gInit->mapI.map.tabGif=NULL;
-
- // lemmingJobAndSprite
- gInit->mapI.lemmingDATA=NULL;
- return 0;
-}
+ int initGame(struct gameInit *gInit){
-int test_O_UD(int UD){
+ int i;
- switch(UD){
- case 4 : return 1;break;
- case 6 : return 1;break;
- case 12 : return 1;break;
- case 14 : return 1;break;
- default: return 0;break;
- }
- return 0;
-}
+ // init liste
+ gInit->t.nbr=0;
+ gInit->o.nbr=0;
+ gInit->s.nbr=0;
+ gInit->l.nbrInput=0;
+ gInit->l.nbr=0;
+ gInit->l.nbrDied=0;
+ gInit->l.nbrSafe=0;
-int creationLemming(struct gameInit *gInit){
- int nbLem;
- struct listeSimplementChainee *k=NULL;
- struct listeSimplementChainee *kTemp=NULL;
- SDL_Surface *sf=NULL;
+ gInit->t.lt=NULL;
+ gInit->o.lo=NULL;
+ gInit->s.ls=NULL;
+ gInit->l.ll=NULL;
- int coorE[10][2];
- int i=0;
- //DEBUT TEST CREATION UN LEMMING
+ // init button state
+ for(i=0;i<NBR_CPT;++i){
+ gInit->cptGame[i]=0;
+ }
+ gInit->cptGame[17]=-1;
- // DEBUT DEBUG: LEMMING COLLISION
- //gInit->mapI.paraMap[1]=2;
- // FIN DEBUG: LEMMING COLLISION
+ // init InfoMap
+ // map name
+ gInit->mapI.name = NULL;
- nbLem=gInit->mapI.paraMap[1];
- //nbLem=1;
- ////-DEBUG-printf("nbLem %d\n",nbLem);
+ // paraMap
+ for(i=0;i<IDENT_COUNT;++i){
+ gInit->mapI.paraMap[i]=0;
+ }
+ // xPos
+ gInit->mapI.xPos=0;
+
+ //MaxFallDistance
+ gInit->mapI.nbrEntry=0;
+ gInit->mapI.MaxFallDistance = 126;
+ gInit->mapI.nuke=0;
+
+ // init MapStyle
+ gInit->mapI.map.style=undefined;
+ gInit->mapI.map.superLemming=0;
+ gInit->mapI.map.tiles=0;
+ gInit->mapI.map.tilesObjet=0;
+ gInit->mapI.map.tilesSteel=0;
+ gInit->mapI.map.tabDataSprO=NULL;
+ gInit->mapI.map.tabGif=NULL;
+
+ // lemmingJobAndSprite
+ gInit->mapI.lemmingDATA=NULL;
- if(gInit->mapI.nbrEntry==0){
- //-DEBUG-printf("ERREUR ALGO: nbrEntry == 0\n");
- return(37);
+ return 0;
}
+ int test_O_UD(int UD){
- // PREMIER CAS
- gInit->l.nbrInput=1;
- gInit->l.ll = malloc(sizeof(struct listeSimplementChainee));
- gInit->l.ll->ID=18;
-
- k=gInit->o.lo;
- while ( k !=NULL ) {
- if( k->ID == 1 ){// Entry detecte
- sf = gInit->mapI.map.tabGif[gInit->mapI.map.tiles*2+k->ID*2+k->data.po->UD+ADD_OBJ];
- coorE[i][0]=k->x+(sf->w/2)-16;
- coorE[i][1]=k->y;
- ++i;
- if(i>=gInit->mapI.nbrEntry){break;}
- if(i>9){//-DEBUG-printf("ERREUR: too many entry\n");
- return(38);}
+ switch(UD){
+ case 4 : return 1;break;
+ case 6 : return 1;break;
+ case 12 : return 1;break;
+ case 14 : return 1;break;
+ default: return 0;break;
}
- k=k->next;
- }
- if(k == NULL){
- //-DEBUG-printf("BUG: NO ENTRY IN THIS LEVEL ...\n");
- return(39);
+ return 0;
}
- gInit->l.ll->x=coorE[0][0];
- gInit->l.ll->y=coorE[0][1];
-
- gInit->l.ll->data.pt=NULL;
- gInit->l.ll->data.po=NULL;
- gInit->l.ll->data.ps=NULL;
- gInit->l.ll->data.pl=malloc(sizeof(struct paraLemming));
-
- gInit->l.ll->data.pl->dir=1;
- gInit->l.ll->data.pl->climber=0;
- gInit->l.ll->data.pl->blocker=0;
- gInit->l.ll->data.pl->bomber=404;
- gInit->l.ll->data.pl->floater=0;
- gInit->l.ll->data.pl->cptFall=0;
- gInit->l.ll->data.pl->cptJump=0;
- gInit->l.ll->data.pl->nuke=0;
- gInit->l.ll->data.pl->cptState=0;
- gInit->l.ll->data.pl->cptBoom=404;
- gInit->l.ll->data.pl->cptFall2=0;
- gInit->l.ll->data.pl->cptBrick=0;
-
- gInit->l.ll->next=NULL;
- if(gInit->mapI.nbrEntry==1){i=0;}
- else {i=1;}
- while(--nbLem > 0){
- // TOUS LES AUTRES CAS
-
- kTemp=malloc(sizeof(struct listeSimplementChainee));
- kTemp=gInit->l.ll;
- gInit->l.ll=NULL;
- gInit->l.ll=malloc(sizeof(struct listeSimplementChainee));
+ int creationLemming(struct gameInit *gInit){
+ int nbLem;
+ struct listeSimplementChainee *k=NULL;
+ struct listeSimplementChainee *kTemp=NULL;
+ SDL_Surface *sf=NULL;
- gInit->l.ll->next=NULL;
- gInit->l.ll->next=malloc(sizeof(struct listeSimplementChainee));
+ int coorE[10][2];
+ int i=0;
+ //DEBUT TEST CREATION UN LEMMING
+
+ // DEBUT DEBUG: LEMMING COLLISION
+ //gInit->mapI.paraMap[1]=2;
+ // FIN DEBUG: LEMMING COLLISION
+
+ nbLem=gInit->mapI.paraMap[1];
+ //nbLem=1;
+ //-DEBUG-printf("nbLem %d\n",nbLem);
+
+ if(gInit->mapI.nbrEntry==0){
+ //-DEBUG-printf("ERREUR ALGO: nbrEntry == 0\n");
+ return(37);
+ }
- gInit->l.ll->next=kTemp;
- gInit->l.nbrInput += 1;
+ // PREMIER CAS
+ gInit->l.nbrInput=1;
+ gInit->l.ll = malloc(sizeof(struct listeSimplementChainee));
gInit->l.ll->ID=18;
- gInit->l.ll->x=coorE[i%gInit->mapI.nbrEntry][0];
- gInit->l.ll->y=coorE[i%gInit->mapI.nbrEntry][1];
+ k=gInit->o.lo;
+ while ( k !=NULL ) {
+ if( k->ID == 1 ){// Entry detecte
+ sf = gInit->mapI.map.tabGif[gInit->mapI.map.tiles*2+k->ID*2+k->data.po->UD+ADD_OBJ];
+ coorE[i][0]=k->x+(sf->w/2)-16;
+ coorE[i][1]=k->y;
+ ++i;
+ if(i>=gInit->mapI.nbrEntry){break;}
+ if(i>9){//-DEBUG-printf("ERREUR: too many entry\n");
+ return(38);}
+ }
+ k=k->next;
+ }
+ if(k == NULL){
+ //-DEBUG-printf("BUG: NO ENTRY IN THIS LEVEL ...\n");
+ return(39);
+ }
+ gInit->l.ll->x=coorE[0][0];
+ gInit->l.ll->y=coorE[0][1];
+ gInit->l.ll->data.pt=NULL;
+ gInit->l.ll->data.po=NULL;
+ gInit->l.ll->data.ps=NULL;
gInit->l.ll->data.pl=malloc(sizeof(struct paraLemming));
+
gInit->l.ll->data.pl->dir=1;
gInit->l.ll->data.pl->climber=0;
gInit->l.ll->data.pl->blocker=0;
- gInit->l.ll->data.pl->bomber=404;
+ gInit->l.ll->data.pl->bomber=-1;
gInit->l.ll->data.pl->floater=0;
gInit->l.ll->data.pl->cptFall=0;
gInit->l.ll->data.pl->cptJump=0;
gInit->l.ll->data.pl->nuke=0;
gInit->l.ll->data.pl->cptState=0;
- gInit->l.ll->data.pl->cptBoom=404;
+ gInit->l.ll->data.pl->cptBoom=-1;
gInit->l.ll->data.pl->cptFall2=0;
gInit->l.ll->data.pl->cptBrick=0;
+
+ gInit->l.ll->next=NULL;
if(gInit->mapI.nbrEntry==1){i=0;}
- else {++i;}
+ else {i=1;}
+ while(--nbLem > 0){
+ // TOUS LES AUTRES CAS
+
+ kTemp=malloc(sizeof(struct listeSimplementChainee));
+ kTemp=gInit->l.ll;
+
+ gInit->l.ll=NULL;
+ gInit->l.ll=malloc(sizeof(struct listeSimplementChainee));
+
+ gInit->l.ll->next=NULL;
+ gInit->l.ll->next=malloc(sizeof(struct listeSimplementChainee));
+
+ gInit->l.ll->next=kTemp;
+
+ gInit->l.nbrInput += 1;
+ gInit->l.ll->ID=18;
+
+ gInit->l.ll->x=coorE[i%gInit->mapI.nbrEntry][0];
+ gInit->l.ll->y=coorE[i%gInit->mapI.nbrEntry][1];
+
+ gInit->l.ll->data.pl=malloc(sizeof(struct paraLemming));
+ gInit->l.ll->data.pl->dir=1;
+ gInit->l.ll->data.pl->climber=0;
+ gInit->l.ll->data.pl->blocker=0;
+ gInit->l.ll->data.pl->bomber=-1;
+ gInit->l.ll->data.pl->floater=0;
+ gInit->l.ll->data.pl->cptFall=0;
+ gInit->l.ll->data.pl->cptJump=0;
+ gInit->l.ll->data.pl->nuke=0;
+ gInit->l.ll->data.pl->cptState=0;
+ gInit->l.ll->data.pl->cptBoom=-1;
+ gInit->l.ll->data.pl->cptFall2=0;
+ gInit->l.ll->data.pl->cptBrick=0;
+ if(gInit->mapI.nbrEntry==1){i=0;}
+ else {++i;}
+ }
+ //FIN TEST CREATION UN LEMMING
+
+ //-DEBUG-printf("REVERSE l.ll\n");
+ gInit->l.ll=(struct listeSimplementChainee*)rev_listeO(gInit->l.ll);
+
+ return 0;
}
- //FIN TEST CREATION UN LEMMING
- ////-DEBUG-printf("REVERSE l.ll\n");
- gInit->l.ll=(struct listeSimplementChainee*)rev_listeO(gInit->l.ll);
+ int paint_terrain (struct gameInit *gInit, int choix){
+ struct listeSimplementChainee *k=NULL;
+ SDL_Rect offset;
+ SDL_Surface *sf;
+ int err=0;
+ int overwrite=0;
+ int remove=0;
+ int paint=0;
+ int tx,ty=0;
+ int cpt=0;
+ int ok=0;
+ Uint32 color;
+
+ // //-DEBUG-printf("LES TERRAINS : ");
+ k=gInit->t.lt;
+ while ( k !=NULL ) {
+ offset.x = k->x;
+ offset.y = k->y;
- return 0;
-}
+ sf = gInit->mapI.map.tabGif[test_O_UD(k->data.pt->modif)+k->ID*2+ADD_OBJ];
+
+ if((k->data.pt->modif != 0)&&
+ (k->data.pt->modif != 2)&&
+ (k->data.pt->modif != 4)&&
+ (k->data.pt->modif != 6)&&
+ (k->data.pt->modif != 8)&&
+ (k->data.pt->modif != 10)&&
+ (k->data.pt->modif != 12)&&
+ (k->data.pt->modif != 14)&&
+ (k->data.pt->modif != 15)
+ ) {
+ //-DEBUG-printf("WTF ... k->data.pt->modif == %d\n",k->data.pt->modif);
+ return(40);
+ }
+ for(ty=k->y;ty<sf->h+k->y;++ty){
-int paint_terrain (struct gameInit *gInit, int choix){
- struct listeSimplementChainee *k=NULL;
- SDL_Rect offset;
- SDL_Surface *sf;
- int err=0;
- int overwrite=0;
- int remove=0;
- int paint=0;
- int tx,ty=0;
- int cpt=0;
- int ok=0;
- Uint32 color;
+ if(ty<0) {ty=-1;continue;}
+ if(ty>=pTerrain->h){break;}
+ if(ty>=LEVEL_HEIGHT) {break;}
- // //-DEBUG-printf("LES TERRAINS : ");
- k=gInit->t.lt;
- while ( k !=NULL ) {
- offset.x = k->x;
- offset.y = k->y;
-
- sf = gInit->mapI.map.tabGif[test_O_UD(k->data.pt->modif)+k->ID*2+ADD_OBJ];
-
- if((k->data.pt->modif != 0)&&
- (k->data.pt->modif != 2)&&
- (k->data.pt->modif != 4)&&
- (k->data.pt->modif != 6)&&
- (k->data.pt->modif != 8)&&
- (k->data.pt->modif != 10)&&
- (k->data.pt->modif != 12)&&
- (k->data.pt->modif != 14)&&
- (k->data.pt->modif != 15)
- ) {
- //-DEBUG-printf("WTF ... k->data.pt->modif == %d\n",k->data.pt->modif);
- return(40);
- }
- for(ty=k->y;ty<sf->h+k->y;++ty){
-
- if(ty<0) {ty=-1;continue;}
- if(ty>=pTerrain->h){break;}
- if(ty>=LEVEL_HEIGHT) {break;}
-
- for(tx=k->x;tx<sf->w+k->x;++tx){
-
- if(tx<0) {tx=-1;continue;}
- if(tx>=pTerrain->w){break;}
- if(tx>=LEVEL_WIDTH) {break;}
-
- overwrite = ((k->data.pt->modif & 8) == 8)? 0 : 1;
- remove = ((k->data.pt->modif & 2) == 2)? 1 : 0;
- if(k->data.pt->modif == 15){
- overwrite=0;
- remove=0;
- }
+ for(tx=k->x;tx<sf->w+k->x;++tx){
+ if(tx<0) {tx=-1;continue;}
+ if(tx>=pTerrain->w){break;}
+ if(tx>=LEVEL_WIDTH) {break;}
- color = get_pixel32(tx-k->x,ty-k->y,sf);
- if(color==ccc_error){return 250;}
- if (color == ccc_black)
- { //putPixel(pStencil,tx,ty , ccc_tEmpty );
- continue;
- }
- paint=0;
- if(!overwrite){
- if((get_pixel32(tx,ty,pStencil)==ccc_error)){return 67;}
- // don't overwrite -> only paint if background is transparent
- if(((get_pixel32(tx,ty,pStencil)>>24) & 0xff ) == 0)
- {// ccc_tEmpty){
- paint=1;
+ overwrite = ((k->data.pt->modif & 8) == 8)? 0 : 1;
+ remove = ((k->data.pt->modif & 2) == 2)? 1 : 0;
+ if(k->data.pt->modif == 15){
+ overwrite=0;
+ remove=0;
}
- } else if(remove){
- // if(((get_pixel32(tx,ty,pStencil)) & ccc_tFull) != 0){
- err=putPixel(pTerrain,tx,ty , gInit->mapI.map.cmap.bgColor);
- if(err!=0){return err;}
- err=putPixel(pStencil,tx,ty , ccc_tRemove );//ccc_tEmpty);
- if(err!=0){return err;}
- // }
- } else {
- paint=1;
+
+ color = get_pixel32(tx-k->x,ty-k->y,sf);
+ if(color==ccc_error){return 250;}
+ if (color == ccc_black)
+ { //putPixel(pStencil,tx,ty , ccc_tEmpty );
+ continue;
}
+ paint=0;
+ if(!overwrite){
+ if((get_pixel32(tx,ty,pStencil)==ccc_error)){return 67;}
+ // don't overwrite -> only paint if background is transparent
+ if(((get_pixel32(tx,ty,pStencil)>>24) & 0xff ) == 0)
+ {// ccc_tEmpty){
+ paint=1;
+ }
+ } else if(remove){
+ // if(((get_pixel32(tx,ty,pStencil)) & ccc_tFull) != 0){
+ err=putPixel(pTerrain,tx,ty , gInit->mapI.map.cmap.bgColor);
+ if(err!=0){return err;}
+ err=putPixel(pStencil,tx,ty , ccc_tRemove );//ccc_tEmpty);
+ if(err!=0){return err;}
+ // }
- if(paint==1){
- if(!overwrite){
- if(!remove){
- err=putPixel(pTerrain,tx,ty ,color);
- if(err!=0){return err;}
- if(k->data.pt->modif==15){
- err=putPixel(pStencil,tx,ty , ccc_tHidden );//ccc_tBrick);
+ } else {
+ paint=1;
+ }
+
+ if(paint==1){
+ if(!overwrite){
+ if(!remove){
+ err=putPixel(pTerrain,tx,ty ,color);
if(err!=0){return err;}
+ if(k->data.pt->modif==15){
+ err=putPixel(pStencil,tx,ty , ccc_tHidden );//ccc_tBrick);
+ if(err!=0){return err;}
+ } else {
+ err=putPixel(pStencil,tx,ty , ccc_tNoOverwrite );//ccc_tBrick);
+ if(err!=0){return err;}
+ }
} else {
- err=putPixel(pStencil,tx,ty , ccc_tNoOverwrite );//ccc_tBrick);
+ err=putPixel(pTerrain,tx,ty ,color);
+ if(err!=0){return err;}
+ err=putPixel(pStencil,tx,ty , ccc_tRemoveNoOverwrite );//ccc_tBrick);
if(err!=0){return err;}
}
} else {
err=putPixel(pTerrain,tx,ty ,color);
if(err!=0){return err;}
- err=putPixel(pStencil,tx,ty , ccc_tRemoveNoOverwrite );//ccc_tBrick);
+ err=putPixel(pStencil,tx,ty , ccc_tFull );//ccc_tBrick);
if(err!=0){return err;}
}
- } else {
- err=putPixel(pTerrain,tx,ty ,color);
- if(err!=0){return err;}
- err=putPixel(pStencil,tx,ty , ccc_tFull );//ccc_tBrick);
- if(err!=0){return err;}
}
- }
- }//fin tx
- }//fin ty
- k=k->next;
- cpt++;
- ok=0;
- //test_FillRect( screen, &screen->clip_rect, SDL_MapRGB( screen->format, 0x0, 0x0, 0x0 ) ); test_blit(pTerrain, &camera, screen, NULL); if( SDL_Flip( screen ) == -1 ) { return 1;} //scanf("%d",&pas);
- }
- // elimination des pixel remove
- for(ty=0;ty<LEVEL_HEIGHT;++ty){
- for(tx=0;tx<LEVEL_WIDTH;++tx){
- color = get_pixel32(tx,ty,pStencil);
- if(color==ccc_tRemove){
- err=putPixel(pStencil,tx,ty , ccc_bgStencil );
- if(err!=0){return err;}
- } else {
- if(color!=ccc_bgStencil){
- err=putPixel(pStencil,tx,ty , ccc_tBrick );
+ }//fin tx
+ }//fin ty
+ k=k->next;
+ cpt++;
+ ok=0;
+ //test_FillRect( screen, &screen->clip_rect, SDL_MapRGB( screen->format, 0x0, 0x0, 0x0 ) ); test_blit(pTerrain, &camera, screen, NULL); if( SDL_Flip( screen ) == -1 ) { return 1;} //scanf("%d",&pas);
+ }
+ // elimination des pixel remove
+ for(ty=0;ty<LEVEL_HEIGHT;++ty){
+ for(tx=0;tx<LEVEL_WIDTH;++tx){
+ color = get_pixel32(tx,ty,pStencil);
+ if(color==ccc_tRemove){
+ err=putPixel(pStencil,tx,ty , ccc_bgStencil );
if(err!=0){return err;}
+ } else {
+ if(color!=ccc_bgStencil){
+ err=putPixel(pStencil,tx,ty , ccc_tBrick );
+ if(err!=0){return err;}
+ }
}
}
}
- }
- // //-DEBUG-printf("LES STEEL : ");
- k=gInit->s.ls;
- while ( k !=NULL ) {
- offset.x = k->x;
- offset.y = k->y;
+ // //-DEBUG-printf("LES STEEL : ");
+ k=gInit->s.ls;
+ while ( k !=NULL ) {
+ offset.x = k->x;
+ offset.y = k->y;
- sf = gInit->mapI.map.tabGif[ADD_OBJ+(gInit->mapI.map.tiles*2)+(gInit->mapI.map.tilesObjet*2)+k->ID];
+ sf = gInit->mapI.map.tabGif[ADD_OBJ+(gInit->mapI.map.tiles*2)+(gInit->mapI.map.tilesObjet*2)+k->ID];
- offset.w = k->data.ps->w;
- offset.h = k->data.ps->h;
- ////-DEBUG-printf("H=)> %d\n",offset.h);
+ offset.w = k->data.ps->w;
+ offset.h = k->data.ps->h;
+ //-DEBUG-printf("H=)> %d\n",offset.h);
- for(ty=k->y;ty<offset.h+k->y;++ty){
+ for(ty=k->y;ty<offset.h+k->y;++ty){
- if(ty<0) {ty=-1;continue;}
- if(ty>pTerrain->h){break;}
- if(ty>=LEVEL_HEIGHT) {break;}
+ if(ty<0) {ty=-1;continue;}
+ if(ty>pTerrain->h){break;}
+ if(ty>=LEVEL_HEIGHT) {break;}
- for(tx=k->x;tx<offset.w+k->x;++tx){
+ for(tx=k->x;tx<offset.w+k->x;++tx){
- if(tx<0) {tx=-1;continue;}
- if(tx>pTerrain->w){break;}
- if(tx>=LEVEL_WIDTH) {break;}
+ if(tx<0) {tx=-1;continue;}
+ if(tx>pTerrain->w){break;}
+ if(tx>=LEVEL_WIDTH) {break;}
- color = get_pixel32(tx,ty,pStencil);
- if(color==ccc_error){return 219;}
- if (color == ccc_black){
- continue;
- } else {
- err=putPixel(pStencil,tx,ty , ccc_s );
- if(err!=0){return err;}
+ color = get_pixel32(tx,ty,pStencil);
+ if(color==ccc_error){return 219;}
+ if (color == ccc_black){
+ continue;
+ } else {
+ err=putPixel(pStencil,tx,ty , ccc_s );
+ if(err!=0){return err;}
+ }
}
}
+ // test_FillRect(pStencil, &offset, ccc_s);
+ k=k->next;
}
- // test_FillRect(pStencil, &offset, ccc_s);
- k=k->next;
- }
- //}
-
- return 0;
-}
-
+ //}
-int miniMap (SDL_Surface *s, int x0, int y0, float coefX, float coefY){
+ return 0;
+ }
- int i,j,stepScreenX,stepScreenY,sizeMiniMapPixel_X,sizeMiniMapPixel_Y,w0,h0,x,y;
- SDL_Rect rect;
- Uint32 err;
- //int cpt=0;
-
- x=x0;
- y=y0;
-
- if((x0 < 0)||
- (y0 < 0)||
- (coefX < 0.)||
- (coefY < 0.)||
- (s->pixels == NULL)
- ){
- //-DEBUG-printf("Bug Error x0 %d y0 %d coefX %f coefY %f s->pixels %p \n",x0,y0,coefX,coefY,s->pixels);
- return 189;
- }
+ int miniMap (SDL_Surface *s, int x0, int y0, float coefX, float coefY){
- ////-DEBUG-printf("x0 %d y0 %d w0 %d h0 %d coefX %f coefY %f s->pixels %p \n",x0,y0,w0,h0,coefX,coefY,s->pixels);
- // if coef >= 1 then zoom++ else zoom--;
- stepScreenX=((coefX>=1.)? 1 : ((int)(1./coefX)));
- stepScreenY=((coefY>=1.)? 1 : ((int)(1./coefY)));
+ int i,j,stepScreenX,stepScreenY,sizeMiniMapPixel_X,sizeMiniMapPixel_Y,w0,h0,x,y;
+ SDL_Rect rect;
+ Uint32 err;
+ //int cpt=0;
- sizeMiniMapPixel_X=((coefX>=1.)? (int)coefX : 1);
- sizeMiniMapPixel_Y=((coefY>=1.)? (int)coefY : 1);
+ x=x0;
+ y=y0;
- /*if(stepX==0){stepX=1;}
- if(stepY==0){stepY=1;}
- if(sizeX==0){sizeX=1;}
- if(sizeY==0){sizeY=1;}
- */
+ if((x0 < 0)||
+ (y0 < 0)||
+ (coefX < 0.)||
+ (coefY < 0.)||
+ (s->pixels == NULL)
+ ){
+ //-DEBUG-printf("Bug Error x0 %d y0 %d coefX %f coefY %f s->pixels %p \n",x0,y0,coefX,coefY,s->pixels);
+ return 189;
+ }
- rect.w=sizeMiniMapPixel_X;
- rect.h=sizeMiniMapPixel_Y;
+ //-DEBUG-printf("x0 %d y0 %d w0 %d h0 %d coefX %f coefY %f s->pixels %p \n",x0,y0,w0,h0,coefX,coefY,s->pixels);
- ////-DEBUG-printf("sx %d sy %d w %d h %d \n",stepX,stepY,sizeX,sizeY);
- ////-DEBUG-printf("h0 %d -> stepY %d, w0 %d -> stepX %d x0 %d y0 %d \n",stepX,stepY,sizeX,sizeY);
+ // if coef >= 1 then zoom++ else zoom--;
+ stepScreenX=((coefX>=1.)? 1 : ((int)(1./coefX)));
+ stepScreenY=((coefY>=1.)? 1 : ((int)(1./coefY)));
- w0=((coefX>=1.)? MINIMAP_MX/sizeMiniMapPixel_X : MINIMAP_MX*stepScreenX);
- h0=((coefY>=1.)? MINIMAP_MY/sizeMiniMapPixel_Y : MINIMAP_MY*stepScreenY);
+ sizeMiniMapPixel_X=((coefX>=1.)? (int)coefX : 1);
+ sizeMiniMapPixel_Y=((coefY>=1.)? (int)coefY : 1);
- //centrage camera, la position du curseur est placé au centre de la minimap
- x0-= (w0/2 - 15);
- y0-= (h0/2 - 10);
+ /*if(stepX==0){stepX=1;}
+ if(stepY==0){stepY=1;}
+ if(sizeX==0){sizeX=1;}
+ if(sizeY==0){sizeY=1;}
+ */
- if(x0<0){x0=0;}
- if(y0<0){y0=0;}
+ rect.w=sizeMiniMapPixel_X;
+ rect.h=sizeMiniMapPixel_Y;
- //centrage camera
- ////-DEBUG-printf("x0 %d w0/2 %d\n",x0,w0/2);
- // x0+=((x0+w0/3)>LEVEL_WIDTH)? 0 : ((coefX>=1.)? ((-w0/3)/(int)coefX) : (int)(((float)(-w0/3))/coefX) );
+ //-DEBUG-printf("sx %d sy %d w %d h %d \n",stepX,stepY,sizeX,sizeY);
+ //-DEBUG-printf("h0 %d -> stepY %d, w0 %d -> stepX %d x0 %d y0 %d \n",stepX,stepY,sizeX,sizeY);
+ w0=((coefX>=1.)? MINIMAP_MX/sizeMiniMapPixel_X : MINIMAP_MX*stepScreenX);
+ h0=((coefY>=1.)? MINIMAP_MY/sizeMiniMapPixel_Y : MINIMAP_MY*stepScreenY);
- if(w0 + x0 >LEVEL_WIDTH){
- if(coefX>1.) {w0=LEVEL_WIDTH-x0;}
- else {x0=LEVEL_HEIGHT-w0;}
- }
- if(h0 + y0 > LEVEL_HEIGHT){
- if(coefY>1.) {h0=LEVEL_HEIGHT-y0;}
- else {y0=LEVEL_HEIGHT-h0;}
- }
+ //centrage camera, la position du curseur est placé au centre de la minimap
+ x0-= (w0/2 - 15);
+ y0-= (h0/2 - 10);
- if((w0 + x0 >LEVEL_WIDTH)||(h0 + y0 > LEVEL_HEIGHT)){return 0;}
+ if(x0<0){x0=0;}
+ if(y0<0){y0=0;}
- 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;}
+ //centrage camera
+ //-DEBUG-printf("x0 %d w0/2 %d\n",x0,w0/2);
+ // x0+=((x0+w0/3)>LEVEL_WIDTH)? 0 : ((coefX>=1.)? ((-w0/3)/(int)coefX) : (int)(((float)(-w0/3))/coefX) );
- 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;}
+ if(w0 + x0 >LEVEL_WIDTH){
+ if(coefX>1.) {w0=LEVEL_WIDTH-x0;}
+ else {x0=LEVEL_HEIGHT-w0;}
+ }
+ if(h0 + y0 > LEVEL_HEIGHT){
+ if(coefY>1.) {h0=LEVEL_HEIGHT-y0;}
+ else {y0=LEVEL_HEIGHT-h0;}
+ }
- err=get_pixel32(x0+i,y0+j,s);
- if(err==ccc_error){return 123;}
+ if((w0 + x0 >LEVEL_WIDTH)||(h0 + y0 > LEVEL_HEIGHT)){return 0;}
- test_FillRect(screen, &rect, err);
+ 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++;
- //printf("cpt = %d\n",cpt);
- return 0;
-}
+ 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;}
-int test_FillRect( SDL_Surface *t, SDL_Rect *to, Uint32 ccc){
+ err=get_pixel32(x0+i,y0+j,s);
+ if(err==ccc_error){return 123;}
- SDL_FillRect(t, to, ccc);
- return 0;
-}
+ test_FillRect(screen, &rect, err);
-int test_blit(SDL_Surface *spr,SDL_Rect *fr1,SDL_Surface *t,SDL_Rect *to1){
+ }
+ }
- /* int size;
- void *temp_pixels = NULL;
+ //printf("cpt = %d\n",cpt);
+ return 0;
+ }
+ int test_FillRect( SDL_Surface *t, SDL_Rect *to, Uint32 ccc){
- size=spr->h*spr->pitch;
- temp_pixels=malloc(size);
+ SDL_FillRect(t, to, ccc);
+ return 0;
+ }
- SDL_LockSurface(spr);
- SDL_LockSurface(t);
- memcpy(temp_pixels,spr->pixels,size);
+ int test_blit(SDL_Surface *spr,SDL_Rect *fr1,SDL_Surface *t,SDL_Rect *to1){
+ /* int size;
+ void *temp_pixels = NULL;
- SDL_UnlockSurface(t);
- SDL_UnlockSurface(spr);*/
- SDL_BlitSurface(spr,fr1, t,to1);
- /* SDL_LockSurface(spr);
- memcpy(spr->pixels,temp_pixels,size);
- SDL_UnlockSurface(spr);
- free(temp_pixels);*/
+ size=spr->h*spr->pitch;
+ temp_pixels=malloc(size);
- return 0;
- // return SDL_BlitSurface(spr,fr1, t,to1);
+ SDL_LockSurface(spr);
+ SDL_LockSurface(t);
+ memcpy(temp_pixels,spr->pixels,size);
-}
-int paint_manip(SDL_Surface *spr,SDL_Rect from,SDL_Surface *t,SDL_Rect to,Uint32 ccc_t, Uint32 ccc_spr, int mode){
+ SDL_UnlockSurface(t);
+ SDL_UnlockSurface(spr);*/
+ SDL_BlitSurface(spr,fr1, t,to1);
+ /* SDL_LockSurface(spr);
+ memcpy(spr->pixels,temp_pixels,size);
+ SDL_UnlockSurface(spr);
- int size,i,j,err;
- void *temp_pixels = NULL;
- Uint32 ccc_temp=0x00000000;
- Uint32 ccc_temp2=0x00000000;
- //FULL
- if(mode==0){
- err=test_blit(spr,&from, t,&to);
- return err;
- }
+ free(temp_pixels);*/
- ////-DEBUG-printf("paint_manip(), from.x==%4i, from.y==%4i, from.h==%4i, from.w==%4i, from to.x==%4i, to.y==%4i\n", from.x, from.y, from.h, from.w, to.x, to.y);
+ return 0;
+ // return SDL_BlitSurface(spr,fr1, t,to1);
- if(from.y<0 || from.y > spr->h) {
- //-DEBUG-printf("simple y\n");
- return 345;
}
- if(from.x<0 || from.x > spr->w) {
- //-DEBUG-printf("simple x\n");
- return 346;
- }
+ int paint_manip(SDL_Surface *spr,SDL_Rect from,SDL_Surface *t,SDL_Rect to,Uint32 ccc_t, Uint32 ccc_spr, int mode, SDL_Surface *stencil){
- if(to.y<0 || to.y > t->h) {
- //-DEBUG-printf("simple y2\n");
- return 91;
- }
+ int size,i,j,err;
+ void *temp_pixels = NULL;
+ Uint32 ccc_temp=0x00000000;
+ Uint32 ccc_temp2=0x00000000;
+ Uint32 ccc_temp3=0x00000000;
+ //FULL
+ if(mode==0){
+ err=test_blit(spr,&from, t,&to);
+ return err;
+ }
- if(to.x<0 || to.x > t->w) {
- //-DEBUG-printf("simple x2\n");
- return 92;
- }
+ //-DEBUG-printf("paint_manip(), from.x==%4i, from.y==%4i, from.h==%4i, from.w==%4i, from to.x==%4i, to.y==%4i\n", from.x, from.y, from.h, from.w, to.x, to.y);
- if(from.y+from.h > spr->h) {
- from.h=spr->h - from.y;
- }
+ if(from.y<0 || from.y > spr->h) {
+ //-DEBUG-printf("simple y\n");
+ return 345;
+ }
- if(from.x+from.w > spr->w) {
- from.w=spr->w - from.x;
- }
+ if(from.x<0 || from.x > spr->w) {
+ //-DEBUG-printf("simple x\n");
+ return 346;
+ }
- if(to.y+from.h > t->h) {
- from.h=t->h - to.y;
- }
+ if(to.y<0 || to.y > t->h) {
+ //-DEBUG-printf("simple y2\n");
+ return 91;
+ }
- if(to.x + from.w > t->w) {
- from.w=t->w - to.x;
- }
+ if(to.x<0 || to.x > t->w) {
+ //-DEBUG-printf("simple x2\n");
+ return 92;
+ }
- size=spr->h*spr->pitch;
- temp_pixels=malloc(size);
+ if(from.y+from.h > spr->h) {
+ from.h=spr->h - from.y;
+ }
- SDL_LockSurface(spr);
- SDL_LockSurface(t);
- memcpy(temp_pixels,spr->pixels,size);
+ if(from.x+from.w > spr->w) {
+ from.w=spr->w - from.x;
+ }
- // NO OVERWRITE
- if(mode==4){
+ if(to.y+from.h > t->h) {
+ from.h=t->h - to.y;
+ }
- for(j=0;j<from.h;j++) {
- for(i=0;i<from.w;i++) {
- /* if((to.y+j)*t->w+(to.x+i)>=(t->w*t->h)){
- //-DEBUG-printf("out of bound1 x=%d + i=%d, y=%d + j=%d * t->w %d == %d >= %d (t->h %d, from.h %d) \n",to.x,i,to.y,j,t->w,(to.y+j)*t->w+(to.x+i),(t->w*t->h),t->h,from.h);
- return 56;
- //continue;
- }*/
- ccc_temp=((Uint32 *)t->pixels)[(to.y+j)*t->w+(to.x+i)];
- ////-DEBUG-printf("ccc_temp1 = %p == %p t->format->colorkey\n",ccc_temp,t->format->colorkey);
- if (ccc_temp!=ccc_t) {
- ((Uint32 *)spr->pixels)[(from.y+j)*spr->w+from.x+i]=ccc_temp;//spr->format->colorkey;
- }
+ if(to.x + from.w > t->w) {
+ from.w=t->w - to.x;
+ }
+
+ size=spr->h*spr->pitch;
+ temp_pixels=malloc(size);
+
+ SDL_LockSurface(spr);
+ SDL_LockSurface(t);
+ memcpy(temp_pixels,spr->pixels,size);
+
+ // NO OVERWRITE
+ if(mode==4){
+
+ for(j=0;j<from.h;j++) {
+ for(i=0;i<from.w;i++) {
+ /* if((to.y+j)*t->w+(to.x+i)>=(t->w*t->h)){
+ //-DEBUG-printf("out of bound1 x=%d + i=%d, y=%d + j=%d * t->w %d == %d >= %d (t->h %d, from.h %d) \n",to.x,i,to.y,j,t->w,(to.y+j)*t->w+(to.x+i),(t->w*t->h),t->h,from.h);
+ return 56;
+ //continue;
+ }*/
+ ccc_temp=((Uint32 *)t->pixels)[(to.y+j)*t->w+(to.x+i)];
+ //-DEBUG-printf("ccc_temp1 = %p == %p t->format->colorkey\n",ccc_temp,t->format->colorkey);
+ if (ccc_temp!=ccc_t) {
+ ((Uint32 *)spr->pixels)[(from.y+j)*spr->w+from.x+i]=ccc_temp;//spr->format->colorkey;
+ }
+ }
}
}
- }
- // VIS ON TERRAIN
- if(mode==8){
- for(j=0;j<from.h;j++) {
- for(i=0;i<from.w;i++) {
- /* if((to.y+j)*t->w+(to.x+i)>=(t->w*t->h)){
- //-DEBUG-printf("out of bound2 x=%d + i=%d, y=%d + j=%d * t->w %d == %d >= %d (t->h %d, from.h %d) \n",to.x,i,to.y,j,t->w,(to.y+j)*t->w+(to.x+i),(t->w*t->h),t->h,from.h);
- return 57;
- //continue;
- }*/
- ccc_temp=((Uint32 *)t->pixels)[(to.y+j)*t->w+(to.x+i)];
- ////-DEBUG-printf("ccc_temp1 = %p == %p ccc_t\n",ccc_temp,ccc_t);
- if (ccc_temp==ccc_t) {
- ((Uint32 *)spr->pixels)[(from.y+j)*spr->w+from.x+i]=ccc_t;//spr->format->colorkey;
-
- }
+ // VIS ON TERRAIN
+ if(mode==8){
+ for(j=0;j<from.h;j++) {
+ for(i=0;i<from.w;i++) {
+ /* if((to.y+j)*t->w+(to.x+i)>=(t->w*t->h)){
+ //-DEBUG-printf("out of bound2 x=%d + i=%d, y=%d + j=%d * t->w %d == %d >= %d (t->h %d, from.h %d) \n",to.x,i,to.y,j,t->w,(to.y+j)*t->w+(to.x+i),(t->w*t->h),t->h,from.h);
+ return 57;
+ //continue;
+ }*/
+ ccc_temp=((Uint32 *)t->pixels)[(to.y+j)*t->w+(to.x+i)];
+ //-DEBUG-printf("ccc_temp1 = %p == %p ccc_t\n",ccc_temp,ccc_t);
+ if (ccc_temp==ccc_t) {
+ ((Uint32 *)spr->pixels)[(from.y+j)*spr->w+from.x+i]=ccc_t;//spr->format->colorkey;
+
+ }
+ }
}
}
- }
- // erease pixel
- if(mode==18){
- for(j=0;j<from.h;j++) {
- for(i=0;i<from.w;i++) {
- /* if((to.y+j)*t->w+(to.x+i)>=(t->w*t->h)){
- //-DEBUG-printf("out of bound2 x=%d + i=%d, y=%d + j=%d * t->w %d == %d >= %d (t->h %d, from.h %d) \n",to.x,i,to.y,j,t->w,(to.y+j)*t->w+(to.x+i),(t->w*t->h),t->h,from.h);
- return 57;
- //continue;
- }*/
- 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)];
- ////-DEBUG-printf("ccc_temp1 = %p == %p ccc_t\n",ccc_temp,ccc_t);
- if (ccc_temp!=ccc_spr) {
- ((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;
+ // erease pixel
+ if(mode==17){
+ for(j=0;j<from.h;j++) {
+ for(i=0;i<from.w;i++) {
+ /* if((to.y+j)*t->w+(to.x+i)>=(t->w*t->h)){
+ //-DEBUG-printf("out of bound2 x=%d + i=%d, y=%d + j=%d * t->w %d == %d >= %d (t->h %d, from.h %d) \n",to.x,i,to.y,j,t->w,(to.y+j)*t->w+(to.x+i),(t->w*t->h),t->h,from.h);
+ return 57;
+ //continue;
+ }*/
+ 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)];
+ //-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;
+ } else {
+ ((Uint32 *)spr->pixels)[(from.y+j)*spr->w+from.x+i]=ccc_temp2;
+ }
}
}
}
- }
-
- SDL_UnlockSurface(t);
- SDL_UnlockSurface(spr);
- test_blit(spr,&from, t,&to);
+ // erease pixel
+ if(mode==18){
+ for(j=0;j<from.h;j++) {
+ for(i=0;i<from.w;i++) {
+ /* if((to.y+j)*t->w+(to.x+i)>=(t->w*t->h)){
+ //-DEBUG-printf("out of bound2 x=%d + i=%d, y=%d + j=%d * t->w %d == %d >= %d (t->h %d, from.h %d) \n",to.x,i,to.y,j,t->w,(to.y+j)*t->w+(to.x+i),(t->w*t->h),t->h,from.h);
+ return 57;
+ //continue;
+ }*/
+ 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)];
+ //-DEBUG-printf("ccc_temp1 = %p == %p ccc_t\n",ccc_temp,ccc_t);
+ if ((ccc_temp!=ccc_spr)&&(ccc_tBrick==ccc_temp2)) {
+ ((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;
+ }
+ }
+ }
+ }
+ // objet trap
+ if(mode==19){
+ for(j=0;j<from.h;j++) {
+ for(i=0;i<from.w;i++) {
+ /* if((to.y+j)*t->w+(to.x+i)>=(t->w*t->h)){
+ //-DEBUG-printf("out of bound2 x=%d + i=%d, y=%d + j=%d * t->w %d == %d >= %d (t->h %d, from.h %d) \n",to.x,i,to.y,j,t->w,(to.y+j)*t->w+(to.x+i),(t->w*t->h),t->h,from.h);
+ return 57;
+ //continue;
+ }*/
+ 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)];
+ //-DEBUG-printf("ccc_temp1 = %p == %p ccc_t\n",ccc_temp,ccc_t);
+ if (ccc_temp!=ccc_spr){
+ ((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;
+ }
+ }
+ }
+ }
- SDL_LockSurface(spr);
- memcpy(spr->pixels,temp_pixels,size);
- SDL_UnlockSurface(spr);
- free(temp_pixels);
+ SDL_UnlockSurface(t);
+ SDL_UnlockSurface(spr);
+ test_blit(spr,&from, t,&to);
- return 0;
+ SDL_LockSurface(spr);
+ memcpy(spr->pixels,temp_pixels,size);
+ SDL_UnlockSurface(spr);
-}
+ free(temp_pixels);
-int paint_objet (struct gameInit *gInit, int cptFps){
- SDL_Rect offset,objetAnim,rStencil;
- SDL_Surface *sf;
- struct listeSimplementChainee *k=NULL;
- int err=0;
- int type=0;
- //int ox,oy;
- int mode=0;
- //Uint32 color,color2,color3;
- //int size;
- //void *temp_pixels = NULL;
-
- //DEBUT TEST: SPR
- k=gInit->o.lo;
- while ( k !=NULL ) {
+ return 0;
- sf = gInit->mapI.map.tabGif[gInit->mapI.map.tiles*2+k->ID*2+k->data.po->UD+ADD_OBJ];
-
- type=gInit->mapI.map.tabDataSprO[k->ID].type;
-
- offset.x = k->x;
- offset.y = k->y;
-
- objetAnim.x = 0;
- objetAnim.h = sf->h/gInit->mapI.map.tabDataSprO[k->ID].state;
- objetAnim.y = (anim_objet(
- gInit->mapI.map.tabDataSprO[k->ID].anim,
- type,
- cptFps,
- gInit->mapI.map.tabDataSprO[k->ID].state,
- &k->data.po->cptState,
- gInit)
- )*(objetAnim.h);
- objetAnim.w = sf->w;
-
- rStencil.x=k->x ;
- rStencil.y=k->y ;
- rStencil.h=objetAnim.h;
- rStencil.w=objetAnim.w;
-
- mode=k->data.po->paintMode;
-
- // check combi impossible
- if((mode!=8)&&((type==3)||(type==4))){
- //-DEBUG-printf("Construction impossible: mode!=%d(8) && type=%d(3 ou 4)\n",mode,type);
- return 56;
- }
- if((mode==8)&&(type==5)){
- //-DEBUG-printf("Construction impossible: mode==%d(8) && type=%d(5)\n",mode,type);
- return 57;
- }
- // fin check
- rStencil.x=0 ;
- rStencil.y=objetAnim.y ;
- if((err=paint_manip(sf,rStencil,pSpr_Lem,offset,gInit->mapI.map.cmap.bgColor,ccc_keyGif,mode))!=0){
- return err;
- }
- k=k->next;
}
- ///FIN TEST: SPR
- return 0;
-}
-
-int paint_objet_stencil (struct gameInit *gInit, int cptFps){
- SDL_Rect offset,objetAnim,rStencil;
- SDL_Surface *sf;
- struct listeSimplementChainee *k=NULL;
- //int res;
- int err=0;
- int type=0;
- int ox,oy;
- int mode=0;
- Uint32 color,color2;//,color3;
- //int size;
- //void *temp_pixels = NULL;
- //DEBUT TEST: SPR
- k=gInit->o.lo;
- while ( k !=NULL ) {
- sf = gInit->mapI.map.tabGif[gInit->mapI.map.tiles*2+k->ID*2+k->data.po->UD+ADD_OBJ];
+ int paint_objet (struct gameInit *gInit, int cptFps){
+ SDL_Rect offset,objetAnim,rStencil;
+ SDL_Surface *sf;
+ struct listeSimplementChainee *k=NULL;
+ int err=0;
+ int type=0;
+ //int ox,oy;
+ //passage==0 => no dig
+ //passage==1 => rest
+ int passage;
+ int mode=0;
+ //Uint32 color,color2,color3;
+ //int size;
+ //void *temp_pixels = NULL;
+
+ //DEBUT TEST: SPR
+ for(passage=0;passage<2;++passage){
+ k=gInit->o.lo;
+ while ( k !=NULL ) {
- type=gInit->mapI.map.tabDataSprO[k->ID].type;
+ sf = gInit->mapI.map.tabGif[gInit->mapI.map.tiles*2+k->ID*2+k->data.po->UD+ADD_OBJ];
+ type=gInit->mapI.map.tabDataSprO[k->ID].type;
+
+ if(((passage==0)&&((type==3)||(type==4)))||
+ ((passage==1)&&(type!=3)&&(type!=4))){
- offset.x = k->x;
- offset.y = k->y;
+ offset.x = k->x;
+ offset.y = k->y;
- objetAnim.x = 0;
- objetAnim.h = sf->h/gInit->mapI.map.tabDataSprO[k->ID].state;
- objetAnim.y = (anim_objet(
- gInit->mapI.map.tabDataSprO[k->ID].anim,
- type,
- cptFps,
- gInit->mapI.map.tabDataSprO[k->ID].state,
- &k->data.po->cptState,
- gInit)
- )*(objetAnim.h);
- objetAnim.w = sf->w;
+ objetAnim.x = 0;
+ objetAnim.h = sf->h/gInit->mapI.map.tabDataSprO[k->ID].state;
+ objetAnim.y = (anim_objet(
+ gInit->mapI.map.tabDataSprO[k->ID].anim,
+ type,
+ cptFps,
+ gInit->mapI.map.tabDataSprO[k->ID].state,
+ &k->data.po->cptState,
+ gInit)
+ )*(objetAnim.h);
+ objetAnim.w = sf->w;
- if(type==6||type==8){
- rStencil.w=objetAnim.w/3;
- rStencil.x=k->x+objetAnim.w/2-rStencil.w/2 ;
+ rStencil.x=k->x ;
rStencil.y=k->y ;
rStencil.h=objetAnim.h;
- } else {
- rStencil.x=k->x;
- rStencil.y=k->y;
rStencil.w=objetAnim.w;
- rStencil.h=objetAnim.h;
- }
- mode=k->data.po->paintMode;
+ mode=k->data.po->paintMode;
- // check combi impossible
- if((mode!=8)&&((type==3)||(type==4))){
- //-DEBUG-printf("Construction impossible: mode!=%d(8) && type=%d(3 ou 4)\n",mode,type);
- return 56;
- }
- if((mode==8)&&(type==5)){
- //-DEBUG-printf("Construction impossible: mode==%d(8) && type=%d(5)\n",mode,type);
- return 57;
- }
- // fin check
- if(type!=4&&type!=3){
- if(type==5){
- rStencil.y=k->y+(rStencil.h/6);
- //rStencil.h=(rStencil.h/6 + (rStencil.h/6)%6)*5;
- rStencil.h=4;
+ // check combi impossible
+ if((mode!=8)&&((type==3)||(type==4))){
+ //-DEBUG-printf("Construction impossible: mode!=%d(8) && type=%d(3 ou 4)\n",mode,type);
+ return 56;
}
- switch(type){
- case 0://passive
- test_FillRect(pStencil, &rStencil, ccc_oPassive);break;
- case 5://trap which makes lemmings drown (water/quick sand/mud)
- test_FillRect(pStencil, &rStencil, ccc_oTrapDrown);break;
- case 6://trap which replaces lemming with death animation
- test_FillRect(pStencil, &rStencil, ccc_oTrapAndNoLem);break;
- case 7://trap which triggers lemming death animation
- test_FillRect(pStencil, &rStencil, ccc_oTrapAndLem);break;
- case 8://exit
- test_FillRect(pStencil, &rStencil, ccc_oExit);break;
- case 32://entry
- test_FillRect(pStencil, &rStencil, ccc_oEntry);
- break;
- default:test_FillRect(pStencil, &rStencil, ccc_oUnknow);break;
+ if((mode==8)&&(type==5)){
+ //-DEBUG-printf("Construction impossible: mode==%d(8) && type=%d(5)\n",mode,type);
+ return 57;
+ }
+ // fin check
+ rStencil.x=0 ;
+ rStencil.y=objetAnim.y ;
+ if((err=paint_manip(sf,rStencil,pSpr_Lem,offset,gInit->mapI.map.cmap.bgColor,ccc_keyGif,mode,NULL))!=0){
+ return err;
}
- switch(mode){
- case 0:break;// FULL
- case 4: {//No Overwrite
- test_blit(pStencilFixe, &rStencil, pStencil, &rStencil);
- break;
- }
- case 8: break;//Vis On Terrain
- default:{//-DEBUG-printf("BUG: value is not 8 4 or 0 : %d \n",mode);
- return(36);}
}
+ k=k->next;
}
- if(mode==8&&(type==3||type==4)){
- for(oy=k->y;oy<rStencil.h+k->y;oy+=1){
+ }//for passage
+ ///FIN TEST: SPR
+ return 0;
+ }
- if(oy<0) {oy=-1;continue;}
- if(oy>pSpr_Lem->h){break;}
- if(oy>=LEVEL_HEIGHT) {break;}
+ int paint_objet_stencil (struct gameInit *gInit, int cptFps){
+ SDL_Rect offset,objetAnim,rStencil;
+ SDL_Surface *sf;
+ struct listeSimplementChainee *k=NULL;
+ //int res;
+ int err=0;
+ int type=0;
+ int ox,oy,i,of;
+ int mode=0;
+ Uint32 color,color2;//,color3;
+ //int size;
+ //void *temp_pixels = NULL;
+ //DEBUT TEST: SPR
+ k=gInit->o.lo;
+ while ( k !=NULL ) {
- if(sf->pixels==NULL){break;}
+ sf = gInit->mapI.map.tabGif[gInit->mapI.map.tiles*2+k->ID*2+k->data.po->UD+ADD_OBJ];
- for(ox=k->x;ox<rStencil.w+k->x;ox+=1){
+ type=gInit->mapI.map.tabDataSprO[k->ID].type;
- if(ox<0) {ox=-1;continue;}
- if(ox>pSpr_Lem->w){break;}
- if(ox>=LEVEL_WIDTH) {break;}
- //if(temp_pixels==NULL){break;}
- //memcpy(sf->pixels,temp_pixels,size);
- color2 = get_pixel32(objetAnim.x+ox-k->x,objetAnim.y+oy-k->y,sf);
- if(color2==ccc_error){return 253;}
- // NO DIG
- color = get_pixel32(ox,oy,pStencil);
- if(color==ccc_error){return 254;}
- if(color==ccc_bgStencil){continue;}
+ offset.x = k->x;
+ offset.y = k->y;
- // pixel transparency in object.gif
- if(type==3){
- err=putPixel(pStencil,ox,oy,ccc_oNoDigLeft);
- if(err!=0){return err;}
- } else {
- err=putPixel(pStencil,ox,oy,ccc_oNoDigRight);
- if(err!=0){return err;}
- }
+ of=gInit->mapI.map.tabDataSprO[k->ID].state;
+
+ objetAnim.x = 0;
+ objetAnim.h = sf->h/of;
+ objetAnim.w = sf->w;
+ objetAnim.y = (anim_objet(
+ gInit->mapI.map.tabDataSprO[k->ID].anim,
+ type,
+ cptFps,
+ of,
+ &k->data.po->cptState,
+ gInit)
+ )*(objetAnim.h);
+
+ if(type==8){
+ rStencil.w=objetAnim.w/8;
+ rStencil.x=k->x+objetAnim.w/2-rStencil.w/2 -1 ;
+ rStencil.y=k->y ;
+ rStencil.h=objetAnim.h;
+ } else {
+ if(type==6){
+ rStencil.x=k->x+objetAnim.w/2-6;
+ rStencil.y=k->y;
+ rStencil.w=10;
+ rStencil.h=objetAnim.h;
+ } else {
+ rStencil.x=k->x;
+ rStencil.y=k->y;
+ rStencil.w=objetAnim.w;
+ rStencil.h=objetAnim.h;
}
}
- //}
- }//FIN ELSE MODE
- k=k->next;
-}
-///FIN TEST: SPR
-return 0;
+
+ mode=k->data.po->paintMode;
+
+ // check combi impossible
+ if((mode!=8)&&((type==3)||(type==4))){
+ //-DEBUG-printf("Construction impossible: mode!=%d(8) && type=%d(3 ou 4)\n",mode,type);
+ return 56;
+ }
+ if((mode==8)&&(type==5)){
+ //-DEBUG-printf("Construction impossible: mode==%d(8) && type=%d(5)\n",mode,type);
+ return 57;
+ }
+ // fin check
+ if(type!=4&&type!=3){
+ if(type==5){
+ rStencil.y=k->y+(rStencil.h/6);
+ //rStencil.h=(rStencil.h/6 + (rStencil.h/6)%6)*5;
+ rStencil.h=10;
+ }
+ switch(type){
+ case 0://passive
+ test_FillRect(pStencil, &rStencil, ccc_oPassive);break;
+ case 5://trap which makes lemmings drown (water/quick sand/mud)
+ test_FillRect(pStencil, &rStencil, ccc_oTrapDrown);break;
+ case 6:{//trap which replaces lemming with death animation
+ --objetAnim.h;
+ if((err=paint_manip(sf,objetAnim,pStencil,offset,ccc_oTrapAndNoLem,ccc_keyGif,19,NULL))!=0){
+ return err;
+ }
+ ++objetAnim.h;
+ test_FillRect(pStencil, &rStencil, ccc_oTrapAndNoLem);
+ break;
+ }
+ case 7:{//trap which triggers lemming death animation
+ //test_FillRect(pStencil, &rStencil, ccc_oTrapAndLem);break;
+ for(i=0;i<of;++i){
+ k->data.po->cptState=i;
+ objetAnim.y = (anim_objet(
+ gInit->mapI.map.tabDataSprO[k->ID].anim,
+ type,
+ i*3,
+ of,
+ &k->data.po->cptState,
+ gInit)
+ )*(objetAnim.h);
+
+ if((err=paint_manip(sf,objetAnim,pStencil,offset,ccc_oTrapAndLem,ccc_keyGif,19,NULL))!=0){
+ return err;
+ }
+ }
+ k->data.po->cptState=0;
+ break;
+ }
+ case 8://exit
+ test_FillRect(pStencil, &rStencil, ccc_oExit);break;
+ case 32://entry
+ test_FillRect(pStencil, &rStencil, ccc_oEntry);
+ break;
+ default:test_FillRect(pStencil, &rStencil, ccc_oUnknow);break;
+ }
+ switch(mode){
+ case 0:break;// FULL
+ case 4: {//No Overwrite
+ test_blit(pStencilFixe, &rStencil, pStencil, &rStencil);
+ break;
+ }
+ case 8: break;//Vis On Terrain
+ default:{//-DEBUG-printf("BUG: value is not 8 4 or 0 : %d \n",mode);
+ return(36);}
+ }
+ }
+ if(mode==8&&(type==3||type==4)){
+ for(oy=k->y;oy<rStencil.h+k->y;oy+=1){
+
+ if(oy<0) {oy=-1;continue;}
+ if(oy>pSpr_Lem->h){break;}
+ if(oy>=LEVEL_HEIGHT) {break;}
+
+ if(sf->pixels==NULL){break;}
+
+ for(ox=k->x;ox<rStencil.w+k->x;ox+=1){
+
+ if(ox<0) {ox=-1;continue;}
+ if(ox>pSpr_Lem->w){break;}
+ if(ox>=LEVEL_WIDTH) {break;}
+
+ //if(temp_pixels==NULL){break;}
+ //memcpy(sf->pixels,temp_pixels,size);
+ color2 = get_pixel32(objetAnim.x+ox-k->x,objetAnim.y+oy-k->y,sf);
+ if(color2==ccc_error){return 253;}
+ // NO DIG
+ color = get_pixel32(ox,oy,pStencil);
+ //error
+ if(color==ccc_error){return 254;}
+ // background
+ if(color==ccc_bgStencil){continue;}
+ // objet
+ if((color&0xbb)==0xbb){continue;}
+ // pixel transparency in object.gif
+ if(type==3){
+ err=putPixel(pStencil,ox,oy,ccc_oNoDigLeft);
+ if(err!=0){return err;}
+ } else {
+ err=putPixel(pStencil,ox,oy,ccc_oNoDigRight);
+ if(err!=0){return err;}
+ }
+ }
+ }
+ //}
+ }//FIN ELSE MODE
+ k=k->next;
+ }
+ ///FIN TEST: SPR
+ return 0;
}
int paint_lemming (struct gameInit *gInit, int cptFps){
//DEBUT TEST: LEM
- SDL_Rect offset,objetAnim;
+ SDL_Rect offset,objetAnim,rect;
SDL_Surface *sf;
struct listeSimplementChainee *k=NULL;
int res;
@@ -2478,11 +2596,11 @@ int paint_lemming (struct gameInit *gInit, int cptFps){
// //-DEBUG-printf("ID= %d k->data.pl->cptState== %d\n",k->ID,k->data.pl->cptState);
// DIED
if(k->data.pl->cptState <= 0 ){
- ////-DEBUG-printf("id ? %d \n",k->ID);
+ //-DEBUG-printf("id ? %d \n",k->ID);
switch(k->ID){
- case 10 : if(k->data.pl->cptBoom!=404) {break;}
+ case 10 : if(k->data.pl->cptBoom!=-1) {break;}
case 8 :
- case 7 :
+ case 7 :k->ID=17;break;// decret de décès
case 5 : k->ID=17;break;// decret de décès
case 9 : k->ID=19;break;// decret de survivant
default:break;
@@ -2539,9 +2657,17 @@ int paint_lemming (struct gameInit *gInit, int cptFps){
break;
}
case 6: {//BLOCKER
- putPixel(pStencil,k->x+sf->w-fx-fs,k->y+fy,ccc_lStopperLeft);
- putPixel(pStencil,k->x+fx+fs,k->y+fy,ccc_lStopperRight);
- //test_FillRect(pStencil, &offset, ccc_lStopper);
+ rect.w=fx+fs-sf->w/2;
+ rect.h=fy+1;
+ rect.y=k->y;
+
+ rect.x=k->x+sf->w-fx-fs;
+ //putPixel(pStencil,k->x+sf->w-fx-fs,k->y+fy,ccc_lStopperLeft);
+ test_FillRect(pStencil, &rect, ccc_lStopperLeft);
+
+ rect.x=k->x+sf->w/2;
+ test_FillRect(pStencil, &rect, ccc_lStopperRight);
+ //putPixel(pStencil,k->x+fx+fs,k->y+fy,ccc_lStopperRight);
break;
}
default:break;
@@ -2593,7 +2719,7 @@ int giveSkill (struct gameInit *gInit, struct listeSimplementChainee* k, int ski
//bomber
case 10 :
if((gInit->mapI.paraMap[6]>0)&&
- (k->data.pl->cptBoom==404)){
+ (k->data.pl->cptBoom==-1)){
if(!gInit->mapI.nuke)
{--gInit->mapI.paraMap[6];}
k->data.pl->cptBoom=5*FPS;
@@ -2604,8 +2730,8 @@ int giveSkill (struct gameInit *gInit, struct listeSimplementChainee* k, int ski
}*/
}
break;
- //blocker
- case 6 : if(((k->ID==0)||((k->ID>9)&&(k->ID<17)))&&
+ //blocker : don't if is jumping
+ case 6 : if(((k->ID==0)||((k->ID>9)&&(k->ID<16)))&&
(gInit->mapI.paraMap[7]>0)
/*&&(k->data.pl->blocker==0)*/
){
@@ -2617,7 +2743,7 @@ int giveSkill (struct gameInit *gInit, struct listeSimplementChainee* k, int ski
//builder
case 11 : if(((k->ID==0)||((k->ID>9)&&(k->ID<17)))&&
(gInit->mapI.paraMap[7]>0)
- /*&&(k->data.pl->blocker==0)*/
+ &&(k->data.pl->cptBrick==0)
){
--gInit->mapI.paraMap[8];
//k->data.pl->cptBrick=12;
@@ -2668,13 +2794,13 @@ int findTerrain( struct gameInit *gInit,int x, int y, int x0){
to.w=1;
to.h=sf->h;
test_FillRect(pStencil, &to, ccc_red);
- to.x=k->x + sf->w;
+ to.x=k->x + sf->w - 1;
to.y=k->y;
to.w=1;
to.h=sf->h;
test_FillRect(pStencil, &to, ccc_red);
to.x=k->x ;
- to.y=k->y + sf->h;
+ to.y=k->y + sf->h - 1;
to.w=sf->w;
to.h=1;
test_FillRect(pStencil, &to, ccc_red);
@@ -2718,7 +2844,7 @@ int paint_cursor(SDL_Surface *dst1,SDL_Surface *dst2, SDL_Surface *src, int x, i
from.y = 4 * (from.h);
f=1;
//begin giveSkill
- if((gInit->cptGame[18]==1)&&(gInit->cptGame[17]!=404)){
+ if((gInit->cptGame[18]==1)&&(gInit->cptGame[17]!=-1)){
switch(gInit->cptGame[17]){
case 2 : err=giveSkill(gInit,k,2);break;//climber
@@ -2737,8 +2863,9 @@ int paint_cursor(SDL_Surface *dst1,SDL_Surface *dst2, SDL_Surface *src, int x, i
default: break;
}
if(err!=0){return err;}
- gInit->cptGame[18]=0;
+ //gInit->cptGame[18]=0;
}
+
//end giveSkill
break;
}
@@ -2758,6 +2885,7 @@ int paint_cursor(SDL_Surface *dst1,SDL_Surface *dst2, SDL_Surface *src, int x, i
}
}
}
+ gInit->cptGame[18]=0;
return 0;
}
@@ -2952,7 +3080,7 @@ int mouse_action (struct gameInit *gInit, int x, int y, int camX, int camY ){
} else {
if(gInit->cptGame[i] == 1){
gInit->cptGame[i] = 0;
- gInit->cptGame[17]=404;
+ gInit->cptGame[17]=-1;
} else {
gInit->cptGame[i] = 1;
gInit->cptGame[17]=i;
@@ -3048,9 +3176,9 @@ int lancement (){
//Initialisation
err=init();
if(err!=0){return err;}
- ////-DEBUG-printf("DONE\n");
+ //-DEBUG-printf("DONE\n");
- ////-DEBUG-printf("DEBUG3: load_file ... \n");
+ //-DEBUG-printf("DEBUG3: load_file ... \n");
//Chargement des fichiers
err=load_files(&gInit);
if(err!=0){return err;}
@@ -3073,7 +3201,7 @@ int lancement (){
inter.w=SCREEN_WIDTH;
inter.h=INTERFACE_HEIGHT;
- ////-DEBUG-printf("DEBUG ludo : camera.w==%i, camera.h==%i\n", camera.w, camera.h);
+ //-DEBUG-printf("DEBUG ludo : camera.w==%i, camera.h==%i\n", camera.w, camera.h);
// init level map (upper part of screen)
test_FillRect( pTerrain, &pTerrain->clip_rect,
@@ -3200,7 +3328,7 @@ int lancement (){
if(paint_stencil==0){
// printf("test %p\n",pSpr_Lem);
test_blit(pSpr_Lem, &camera, screen, NULL);
- err=miniMap (pSpr_Lem,mouseX+camera.x,mouseY+camera.y,5.,5.);
+ err=miniMap (pSpr_Lem,mouseX+camera.x,mouseY+camera.y,5.,5.);//0.10,0.10);
if( err != 0){ return err;}
} else {
test_blit(pStencil, &camera, screen, NULL);
@@ -3211,7 +3339,7 @@ int lancement (){
/* FPS counter */
- ////-DEBUG-printf("(tick %ld > fps_start %d +500)\n",tick,fps_start);
+ //-DEBUG-printf("(tick %ld > fps_start %d +500)\n",tick,fps_start);
// refresh fps all 500 ms
if(tick > fps_start + 500)
{
@@ -3226,7 +3354,7 @@ int lancement (){
//if(SDL_GetTicks()==240000){
//decalFps = 99;
quit=1;
- }}
+ }
*/
// limte fps
@@ -3266,16 +3394,17 @@ int lancement (){
return(43);
} else {
temps = SDL_GetTicks();
- ////-DEBUG-printf("cptFps = %d, time: %ld:%ld:%ld \n",cptFps,temps/(1000*3600),(temps/(1000*60))%60,(temps/1000)%60);
+ //-DEBUG-printf("cptFps = %d, time: %ld:%ld:%ld \n",cptFps,temps/(1000*3600),(temps/(1000*60))%60,(temps/1000)%60);
}
cptFps++;
+
//quit = 1;
- }
+}
- //On libère les images et on quitte SDL
- err=clean_up();
- if(err!=0){return err;}
+//On libère les images et on quitte SDL
+err=clean_up();
+if(err!=0){return err;}
- return 0;
+return 0;
}
diff --git a/sdl-test/SDL_tuto/TestParserLemmingsLVL/parse_ini.yy b/sdl-test/SDL_tuto/TestParserLemmingsLVL/parse_ini.yy
index 48042e0..9ad0a09 100644
--- a/sdl-test/SDL_tuto/TestParserLemmingsLVL/parse_ini.yy
+++ b/sdl-test/SDL_tuto/TestParserLemmingsLVL/parse_ini.yy
@@ -32,10 +32,16 @@
const int SCREEN_BPP = 32;
//MINIMAP
+ /*
#define MINIMAP_X0 420 //636
#define MINIMAP_Y0 365
#define MINIMAP_MX 210 //464
-#define MINIMAP_MY 48 //120
+#define MINIMAP_MY 48 //120*/
+
+#define MINIMAP_X0 420
+#define MINIMAP_Y0 325
+#define MINIMAP_MX 350
+#define MINIMAP_MY 175
const int INTER_BUTTON_X = 0;
const int INTER_BUTTON_Y = 50;
@@ -373,14 +379,14 @@
int dir; // direction of lemming; default=1;
int climber; // skill climber; default = 0;
int blocker; // skill blocker; default = 0;
- int bomber; // skill bomber; default = 404;
+ int bomber; // skill bomber; default = -1;
int floater; // skill floater; default = 0;
int nuke; // nuked or not; default=0;
int cptFall; // count number of pixel when lemming falling;default = 0;
int cptFall2;// count number of pixel when lemming falling;default = 0;
int cptJump; // count number of pixel when lemming jumping;default = 0;
int cptBrick; // count number of brick ;default = 0;
- int cptBoom; // count number of boom ;default = 404;
+ int cptBoom; // count number of boom ;default = -1;
int cptState; // count number of frame for an animation at once, default=0;
};
@@ -435,7 +441,7 @@
// 14 : CURSOR STATE
// 15 : FREE CPT: for all need it ...; default=0;
// 16 : NBR_ENTRY OPEN; default=0;
- // 17 : clic on mouse on lemning skill; default=404;
+ // 17 : clic on mouse on lemning skill; default=-1;
// 18 : clic on mouse on lemning;default=0;
int cptGame[NBR_CPT]; // default=0;
};
@@ -502,7 +508,7 @@
int paint_terrain (struct gameInit *gInit, int choix);
- int paint_manip(SDL_Surface *spr,SDL_Rect from,SDL_Surface *t,SDL_Rect to,Uint32 ccc_t, Uint32 ccc_spr, int mode);
+ int paint_manip(SDL_Surface *spr,SDL_Rect from,SDL_Surface *t,SDL_Rect to,Uint32 ccc_t, Uint32 ccc_spr, int mode, SDL_Surface *stencil);
int paint_objet (struct gameInit *gInit, int cptFps);
@@ -543,13 +549,13 @@
int lancement();
int test_blit(SDL_Surface *spr,SDL_Rect* from,SDL_Surface *t,SDL_Rect* to);
-
+
int test_FillRect( SDL_Surface *t, SDL_Rect *to, Uint32 ccc);
-
+
int miniMap (SDL_Surface *s, int x0, int y0, float coefX, float coefY);
int paint_stencil=0;
-
+
%}
%parse-param { struct gameInit *gInit }