diff --git a/Dark Souls Boss Fight Meme Template Why do I hear Boss Music Template.mp3 b/Dark Souls Boss Fight Meme Template Why do I hear Boss Music Template.mp3 deleted file mode 100755 index cb152be..0000000 Binary files a/Dark Souls Boss Fight Meme Template Why do I hear Boss Music Template.mp3 and /dev/null differ diff --git a/animebg/1.png b/animebg/1.png new file mode 100755 index 0000000..24c01fb Binary files /dev/null and b/animebg/1.png differ diff --git a/animebg/10.png b/animebg/10.png new file mode 100755 index 0000000..de89323 Binary files /dev/null and b/animebg/10.png differ diff --git a/animebg/11.png b/animebg/11.png new file mode 100755 index 0000000..de89323 Binary files /dev/null and b/animebg/11.png differ diff --git a/animebg/12.png b/animebg/12.png new file mode 100755 index 0000000..de89323 Binary files /dev/null and b/animebg/12.png differ diff --git a/animebg/13.png b/animebg/13.png new file mode 100755 index 0000000..de89323 Binary files /dev/null and b/animebg/13.png differ diff --git a/animebg/14.png b/animebg/14.png new file mode 100755 index 0000000..de89323 Binary files /dev/null and b/animebg/14.png differ diff --git a/animebg/15.png b/animebg/15.png new file mode 100755 index 0000000..de89323 Binary files /dev/null and b/animebg/15.png differ diff --git a/animebg/16.png b/animebg/16.png new file mode 100755 index 0000000..de89323 Binary files /dev/null and b/animebg/16.png differ diff --git a/animebg/17.png b/animebg/17.png new file mode 100755 index 0000000..ebaa2c3 Binary files /dev/null and b/animebg/17.png differ diff --git a/animebg/18.png b/animebg/18.png new file mode 100755 index 0000000..ebaa2c3 Binary files /dev/null and b/animebg/18.png differ diff --git a/animebg/19.png b/animebg/19.png new file mode 100755 index 0000000..ebaa2c3 Binary files /dev/null and b/animebg/19.png differ diff --git a/animebg/2.png b/animebg/2.png new file mode 100755 index 0000000..24c01fb Binary files /dev/null and b/animebg/2.png differ diff --git a/animebg/20.png b/animebg/20.png new file mode 100755 index 0000000..ebaa2c3 Binary files /dev/null and b/animebg/20.png differ diff --git a/animebg/21.png b/animebg/21.png new file mode 100755 index 0000000..ebaa2c3 Binary files /dev/null and b/animebg/21.png differ diff --git a/animebg/22.png b/animebg/22.png new file mode 100755 index 0000000..ebaa2c3 Binary files /dev/null and b/animebg/22.png differ diff --git a/animebg/23.png b/animebg/23.png new file mode 100755 index 0000000..ebaa2c3 Binary files /dev/null and b/animebg/23.png differ diff --git a/animebg/24.png b/animebg/24.png new file mode 100755 index 0000000..ebaa2c3 Binary files /dev/null and b/animebg/24.png differ diff --git a/animebg/3.png b/animebg/3.png new file mode 100755 index 0000000..24c01fb Binary files /dev/null and b/animebg/3.png differ diff --git a/animebg/4.png b/animebg/4.png new file mode 100755 index 0000000..24c01fb Binary files /dev/null and b/animebg/4.png differ diff --git a/animebg/5.png b/animebg/5.png new file mode 100755 index 0000000..24c01fb Binary files /dev/null and b/animebg/5.png differ diff --git a/animebg/6.png b/animebg/6.png new file mode 100755 index 0000000..24c01fb Binary files /dev/null and b/animebg/6.png differ diff --git a/animebg/7.png b/animebg/7.png new file mode 100755 index 0000000..24c01fb Binary files /dev/null and b/animebg/7.png differ diff --git a/animebg/8.png b/animebg/8.png new file mode 100755 index 0000000..24c01fb Binary files /dev/null and b/animebg/8.png differ diff --git a/animebg/9.png b/animebg/9.png new file mode 100755 index 0000000..de89323 Binary files /dev/null and b/animebg/9.png differ diff --git a/bg.c b/bg.c new file mode 100755 index 0000000..8bb117d --- /dev/null +++ b/bg.c @@ -0,0 +1,281 @@ +#include +#include "bg.h" +#include "text.h" +#include +#include +#include + +Mix_Music* initsound (char ch[]) +{ + return Mix_LoadMUS (ch); +} + +void initialiser_imageBIRDS(image *imge) +{ +imge->img=IMG_Load("music.png"); +if (imge->img == NULL) { +printf("unable to load background image %s\n", Mix_GetError()); +return;} +imge->pos_img_ecran.x=10; +imge->pos_img_ecran.y=100; +imge->pos_img_affiche.x=0; +imge->pos_img_affiche.y=0; +imge->pos_img_affiche.h=164; +imge->pos_img_affiche.w=161; +} +void afficher_imageBIRDS(SDL_Surface *screen, image imge) + { + SDL_BlitSurface(imge.img,NULL,screen, &imge.pos_img_ecran); + } +void initBack(background *b,char ch[]) +{ + b->img = IMG_Load(ch); + if ( b->img == NULL) + { + return; + } + b->pos1.x=0; + b->pos1.y=0; + b->pos2.x=0; + b->pos2.y=0; + b->pos2.w=(1920); + b->pos2.h=(1080); + +} +void initobs1(background *obs1,char ch[]) +{ + obs1->img = IMG_Load(ch); + if ( obs1->img == NULL) + { + return; + } + obs1->pos1.x=10; + obs1->pos1.y=730; + obs1->pos2.x=0; + obs1->pos2.y=0; + obs1->pos2.w=(1920); + obs1->pos2.h=(1080); + + +} +void initAnime ( background BG[] , char ch[] , char ext[] , int n , int x , int y , int w , int h) +{ + int i; + char chi[4], chemin [100]; + for (i=0;ipos2.x>7080) + { + b->pos2.x=0; + } + else + b->pos2.x=b->pos2.x+6; + + } + +} +void scrollinganime (background T[], int direction ) +{ + int i; + if (direction==1) + { + for (i=0;i<24;i++) + { + if((T[i].pos2.x>7080)) + { + T[i].pos2.x=0; + } + else + { + T[i].pos2.x=T[i].pos2.x+6; + } + + } + } +} +void caranim (background T[], int direction ) +{ + int i; + if (direction==3) + { + for (i=0;i<12;i++) + { + if ((T[i].pos1.y >=550)) + { + T[i].pos1.y=T[i].pos1.y-5; + } + } + } + else if (direction==4) + { + for (i=0;i<12;i++) + { + if ((T[i].pos1.y < 950)) + { + T[i].pos1.y=T[i].pos1.y+5; + + } + } + } +} + +SDL_Color GetPixel(SDL_Surface *p , int x , int y) +{ + SDL_Color color; + Uint32 col=0; + + char * Pos = (char*)p->pixels; + Pos += (p->pitch * y); + Pos += (p->format->BytesPerPixel * x); + memcpy (&col ,Pos, p->format->BytesPerPixel ); + + SDL_GetRGB(col , p->format,&color.r , &color.g,&color.b ); + return color; + +} + +void tab(car *C) +{ + + C->T[0].x=C->b[0].pos1.x; + C->T[0].y=C->b[0].pos1.y; + C->T[0].c=0; + + C->T[1].x=C->b[0].pos1.x+C->b[0].pos2.w/2; + C->T[1].y=C->b[0].pos1.y; + C->T[1].c=0; + + C->T[2].x=C->b[0].pos1.x + C->b[0].pos2.w; + C->T[2].y=C->b[0].pos1.y; + C->T[2].c=0; + + C->T[3].x=C->b[0].pos1.x+C->b[0].pos2.w; + C->T[3].y=C->b[0].pos1.y + C->b[0].pos2.h /2; + C->T[3].c=0; + + C->T[4].x=C->b[0].pos1.x+C->b[0].pos2.w; + C->T[4].y=C->b[0].pos1.y+C->b[0].pos2.h; + C->T[4].c=0; + + C->T[5].x=C->b[0].pos1.x + C->b[0].pos2.w/2; + C->T[5].y=C->b[0].pos1.y+ C->b[0].pos2.h ; + C->T[5].c=0; + + C->T[6].x=C->b[0].pos1.x; + C->T[6].y=C->b[0].pos1.y+C->b[0].pos2.h; + C->T[6].c=0; + + C->T[7].x=C->b[0].pos1.x; + C->T[7].y=C->b[0].pos1.y+C->b[0].pos2.h/2; + C->T[7].c=0; + + +} + +void collision (car *C , background B , int *done) +{ + SDL_Color color ,color2; + int i=0; + color.r=0; + color.g=0; + color.b=0; + tab(C); + while (i<8) + { + color2=GetPixel(B.img , C->T[i].x +B.pos2.x , C->T[i].y+B.pos2.y); + if ((color.r==color2.r)&&(color.g==color2.g)&&(color.b==color2.b) ) + { + C->T[i].c = 1; + } + if ( ( i==3) && ((color.r==0)&&(color.g==0)&&(color.b==255) ) ) + *done=1; + i++; + } +} + + +void afficher(background b,SDL_Surface *screen) +{ + SDL_BlitSurface(b.img,&b.pos2,screen,&b.pos1); +} + +void liberer( background b) +{ + SDL_FreeSurface(b.img); +} +void freeAnime (background T[],int n) +{ + int i; + for (i=0;i +#include +#include +#include +#define SCREEN_W 1920 +#define SCREEN_H 720 +#include "text.h" +typedef struct +{ +char url; +SDL_Rect pos_img_affiche; +SDL_Rect pos_img_ecran; +SDL_Surface *img; +}image; +typedef struct +{ + SDL_Rect pos1; + SDL_Rect pos2; + SDL_Surface *img; +}background; + +Mix_Music* initsound (); + +typedef struct +{ + int score; + int temps; + char playername[20]; +}scoreinfo; + +typedef struct +{ + int x; + int y; + int c; +}point; + +typedef struct +{ + point T[8]; + background b[13]; +}car; + + +void initobs1(background *obs1,char ch[]); + +void initBack( background *b,char ch[]); + + +SDL_Color GetPixel(SDL_Surface *p , int x , int y); +void collision (car *C , background B , int *done); +void tab(car *C); + + +void initialiser_imageBIRDS(image *imge); +void afficher_imageBIRDS(SDL_Surface *screen, image imge); + + + +void scrolling (background * b, int direction ); +void afficher(background b,SDL_Surface *screen); +void initAnime ( background BG[] , char ch[] , char ext[] , int n , int x , int y , int w , int h); +void initAnime2 ( background BG[] , char ch[] , char ext[], int n,int x,int y); +void savescore(scoreinfo xs,char *ch); +void bestscore(char *ch,scoreinfo ts[],Text t2,SDL_Surface *screen); +void caranim (background T[], int direction ); +void scrollinganime (background T[], int direction ); +void playAnime (background T[], SDL_Surface *screen , int n,int *i); + + +void liberer( background b); +void freeAnime (background T[],int n); +#endif diff --git a/bg.o b/bg.o new file mode 100644 index 0000000..d59f148 Binary files /dev/null and b/bg.o differ diff --git a/bgm1.mp3 b/bgm1.mp3 deleted file mode 100755 index 2f08230..0000000 Binary files a/bgm1.mp3 and /dev/null differ diff --git a/car animation/1.png b/car animation/1.png new file mode 100755 index 0000000..e7e85d3 Binary files /dev/null and b/car animation/1.png differ diff --git a/car animation/10.png b/car animation/10.png new file mode 100755 index 0000000..7232393 Binary files /dev/null and b/car animation/10.png differ diff --git a/car animation/11.png b/car animation/11.png new file mode 100755 index 0000000..d34dd36 Binary files /dev/null and b/car animation/11.png differ diff --git a/car animation/12.png b/car animation/12.png new file mode 100755 index 0000000..180aaaf Binary files /dev/null and b/car animation/12.png differ diff --git a/car animation/2.png b/car animation/2.png new file mode 100755 index 0000000..170fa87 Binary files /dev/null and b/car animation/2.png differ diff --git a/car animation/3.png b/car animation/3.png new file mode 100755 index 0000000..2d958a6 Binary files /dev/null and b/car animation/3.png differ diff --git a/car animation/4.png b/car animation/4.png new file mode 100755 index 0000000..408e7b8 Binary files /dev/null and b/car animation/4.png differ diff --git a/car animation/5.png b/car animation/5.png new file mode 100755 index 0000000..450dc3d Binary files /dev/null and b/car animation/5.png differ diff --git a/car animation/6.png b/car animation/6.png new file mode 100755 index 0000000..60dc33a Binary files /dev/null and b/car animation/6.png differ diff --git a/car animation/7.png b/car animation/7.png new file mode 100755 index 0000000..e20e677 Binary files /dev/null and b/car animation/7.png differ diff --git a/car animation/8.png b/car animation/8.png new file mode 100755 index 0000000..a57d5d9 Binary files /dev/null and b/car animation/8.png differ diff --git a/car animation/9.png b/car animation/9.png new file mode 100755 index 0000000..1e2cfe6 Binary files /dev/null and b/car animation/9.png differ diff --git a/fonction.c b/fonction.c deleted file mode 100755 index f9a90f0..0000000 --- a/fonction.c +++ /dev/null @@ -1,603 +0,0 @@ -#include -#include "fonction.h" -#include "text.h" -#include -#include -#include - -void init_hero(hero* h,int choix) -{ - - h->heroright[0]= IMG_Load("images/pr2.png"); - h->heroleft[0]= IMG_Load("images/pl2.png"); - - h->heroright[1]= IMG_Load("images/pr3.png"); - h->heroleft[1]= IMG_Load("images/pl3.png"); - - h->heroright[2]= IMG_Load("images/pr4.png"); - h->heroleft[2]= IMG_Load("images/pl4.png"); - - h->heroright[3]= IMG_Load("images/pr5.png"); - h->heroleft[3]= IMG_Load("images/pl5.png"); - - h->heroright[4]= IMG_Load("images/pr6.png"); - h->heroleft[4]= IMG_Load("images/pl6.png"); - - h->heroright[5]= IMG_Load("images/pr7.png"); - h->heroleft[5]= IMG_Load("images/pl7.png"); - - - - - h->idleright[0]= IMG_Load("images/pr1.png"); - h->idleright[1]= IMG_Load("images/afk2.png"); - h->idleright[2]= IMG_Load("images/afk3.png"); - h->idleright[3]= IMG_Load("images/afk4.png"); - h->idleright[4]= IMG_Load("images/afk5.png"); - - h->idleleft[0]= IMG_Load("images/pl1.png"); - h->idleleft[1]= IMG_Load("images/afkleft2.png"); - h->idleleft[2]= IMG_Load("images/afkleft3.png"); - h->idleleft[3]= IMG_Load("images/afkleft4.png"); - h->idleleft[4]= IMG_Load("images/afkleft5.png"); - - - - h->jumpright[0]= IMG_Load("images/jr1.png"); - h->jumpright[1]= IMG_Load("images/jr2.png"); - h->jumpright[2]= IMG_Load("images/jr3.png"); - h->jumpright[3]= IMG_Load("images/jr4.png"); - h->jumpright[4]= IMG_Load("images/jr5.png"); - h->jumpright[5]= IMG_Load("images/jr6.png"); - h->jumpright[6]= IMG_Load("images/jr7.png"); - h->jumpright[7]= IMG_Load("images/jr8.png"); - h->jumpright[8]= IMG_Load("images/jr9.png"); - h->jumpright[9]= IMG_Load("images/jr10.png"); - - - - h->jumpleft[0]= IMG_Load("images/jl1.png"); - h->jumpleft[1]= IMG_Load("images/jl2.png"); - h->jumpleft[2]= IMG_Load("images/jl3.png"); - h->jumpleft[3]= IMG_Load("images/jl4.png"); - h->jumpleft[4]= IMG_Load("images/jl5.png"); - h->jumpleft[5]= IMG_Load("images/jl6.png"); - h->jumpleft[6]= IMG_Load("images/jl7.png"); - h->jumpleft[7]= IMG_Load("images/jl8.png"); - h->jumpleft[8]= IMG_Load("images/jl9.png"); - h->jumpleft[9]= IMG_Load("images/jl10.png"); - - - h->fallright[0]= IMG_Load("images/jr11.png"); - h->fallright[1]= IMG_Load("images/jr12.png"); - h->fallright[2]= IMG_Load("images/jr13.png"); - h->fallright[3]= IMG_Load("images/jr14.png"); - - - h->fallleft[0]= IMG_Load("images/jl11.png"); - h->fallleft[1]= IMG_Load("images/jl12.png"); - h->fallleft[2]= IMG_Load("images/jl13.png"); - h->fallleft[3]= IMG_Load("images/jl14.png"); - - - h->heroposition.x = 100; - h->heroposition.y = 600; - h->heroposition.w = 120; - h->heroposition.h = 80; - h->sens= 0; - h->frame= 0; - h->idle=0; - h->jump=0; - h->fall=0; - - - - h->heroisjumping = 0; - h->speedup = 0 ; - h->speeddown = 10 ; - h->directionjump = 1; - h->ground = 600 ; - h->gravity = 0; - h->herospeed=0; - - h->vitesse = 5; - h->acceleration = 0; -} -void blit_hero( hero* h,SDL_Surface *screen) -{ - if ( h->sens == 0 ) - { - SDL_BlitSurface(h->heroright[h->frame],NULL,screen,&h->heroposition); - } - else if (h->sens == 1) - { - SDL_BlitSurface(h->heroleft[h->frame],NULL,screen,&h->heroposition); - } - - - - else if(h->sens == -1) - { - SDL_BlitSurface(h->idleright[h->idle],NULL,screen,&h->heroposition); - } - else if(h->sens==-2) - { - SDL_BlitSurface(h->idleleft[h->idle],NULL,screen,&h->heroposition); - } - - - - else if(h->sens == 3) - { - SDL_BlitSurface(h->jumpright[h->jump],NULL,screen,&h->heroposition); - } - else if(h->sens == -3) - { - SDL_BlitSurface(h->jumpleft[h->jump],NULL,screen,&h->heroposition); - } - - - - else if(h->sens == 4) - { - SDL_BlitSurface(h->fallright[h->fall],NULL,screen,&h->heroposition); - } - else if(h->sens == -4) - { - SDL_BlitSurface(h->fallleft[h->fall],NULL,screen,&h->heroposition); - } - -} - - - -void animation (hero* h,int choix) -{ -h->frame++; -if(h->frame >=6) -{ -h->frame=1; -} -SDL_Delay(20); -} - - - -void idle(hero* h) -{ -h->idle++; -if(h->idle>=5) -{ -h->idle=0; -} -SDL_Delay(100); -} - - - - -void jumpanimation(hero* h) -{ - h->jump++; - if(h->jump>=10) - { - h->jump=0; - } - SDL_Delay(1); -} - - - -void fall(hero* h) -{ - h->fall++; - if(h->fall>=4) - { - h->fall=0; - } - SDL_Delay(200); -} - - - -void Free_hero(hero* h) -{ - int i; - int j; - int k; - int q; - for (i=0;i<6;i++) - { - SDL_FreeSurface(h->heroright[i]); - SDL_FreeSurface(h->heroleft[i]); - } - for (j=0;j<5;j++) - { - SDL_FreeSurface(h->idleright[j]); - SDL_FreeSurface(h->idleleft[j]); - } - for (k=0;k<4;k++) - { - SDL_FreeSurface(h->fallright[k]); - SDL_FreeSurface(h->fallleft[k]); - } - for (q=0;q<10;q++) - { - SDL_FreeSurface(h->jumpright[q]); - SDL_FreeSurface(h->jumpleft[q]); - } - -} - - - -void jump(hero* h) -{ - - if ( h->heroisjumping == 1 ) - { - if ( h->gravity == 0 ) - { - h->heroposition.y -= (h->heroposition.y/22); - SDL_Delay(h->speedup); - } - if( h->speedup <= 5) - { - h->speedup +=1; - } - - - if ( h->ground - h->heroposition.y >= 250 ) - { - h->gravity = 1; - } - if ( h->gravity == 1 ) - { - SDL_Delay(h->speeddown); - if ( h->speeddown >=1 ) - { - h->speeddown -= 1; - } - if ( h->heroposition.y >= h->ground ) - { - h->heroposition.y = h->ground; - restart_jump(h); - h->heroisjumping = 0; - } - if ( h->heroposition.y != h->ground ) - { - h->heroposition.y += (h->heroposition.y/22); - } - } - } -} -void restart_jump ( hero* h ) -{ - h->speedup = 0; - h->gravity = 0; - h->speeddown = 20; -} -void deplacer_perso(hero *p,Uint32 dt) -{ - int dx; - dx=((p->acceleration/2)*(dt*dt))+(p->vitesse*dt); - if((p->sens==1)&&(p->T[7].c!=1)) - { - p->heroposition.x-=(dx/10); - //p->heroposition.x--; - } - else if((p->sens==0)&&(p->T[3].c!=1)) - { - p->heroposition.x+=(dx/10); - //p->heroposition.x++; - } -} -int choix_hero() -{ - SDL_Event event; - int continuer=1; - while(continuer == 1) - { - - SDL_PollEvent(&event); - switch(event.type) - { - case SDL_QUIT: - continuer=0; - - break; - - case SDL_KEYDOWN: - { - switch(event.key.keysym.sym) - { - case SDLK_ESCAPE: - continuer=0; - break; - case SDLK_RIGHT : - { - return 1; - } - break; - case SDLK_LEFT : - { - return 2; - } - break; - } - break; - } - } - } -} -//background - -Mix_Music* initsound (char ch[]) -{ - return Mix_LoadMUS (ch); -} - - -void initBack(background *b,char ch[]) -{ - b->img = IMG_Load(ch); - if ( b->img == NULL) - { - return; - } - b->pos1.x=0; - b->pos1.y=0; - b->pos2.x=0; - b->pos2.y=0; - b->pos2.w=(5768); - b->pos2.h=(1050); - -} - -void initBack2(background *b,char ch[]) -{ - b->img = SDL_LoadBMP(ch); - if ( b->img == NULL) - { - return; - } - b->pos1.x=0; - b->pos1.y=0; - b->pos2.x=0; - b->pos2.y=0; - b->pos2.w=(5768); - b->pos2.h=(1050); - -} - - -void initBut(background *score,char ch[]) -{ - score->img = IMG_Load(ch); - if ( score->img == NULL) - { - return; - } - score->pos1.x=800; - score->pos1.y=10; - score->pos2.x=0; - score->pos2.y=0; - score->pos2.w=(5768); - score->pos2.h=(1050); - -} - - - -void scrolling (background * b, int direction , Uint32 dt , hero *p ) -{ - int dx; - dx=p->heroposition.x; - if (direction==1) - { - if(b->pos2.x>2000) - { - b->pos2.x=0; - } - else - b->pos2.x=dx; - } - else if (direction==2) - if (b->pos2.x<0) - { - - } - else - b->pos2.x=dx; - /*else if (direction==3) - if (b->pos2.y <-50) - { - - } - else - b->pos2.y=dx; - - else if (direction==4) - if (b->pos2.y> 150) - { - - } - else - b->pos2.y=dx;*/ -} - - - -void savescore(scoreinfo xs,char *ch) -{ - FILE* f; - f= fopen(ch, "a"); - if(f== NULL) - { - printf("error"); - } - - printf("Donner le nom de joueur: "); - scanf("%s",xs.playername); - printf("\n"); - fprintf(f, "%d %d %s\n", xs.score, (xs.temps/1000), xs.playername); - - fclose(f); - -} - - -void bestscore(char *ch,scoreinfo ts[],Text t2, SDL_Surface *screen) -{ - char xch[999]; - int n=0; - int i,j; - int max; - scoreinfo tampon; - FILE* f; - f= fopen(ch, "r"); - if(f== NULL) - { - printf("error"); - } - while( fscanf(f, "%d %d %s\n",&ts[n].score,&ts[n].temps,ts[n].playername)!= EOF ) - { - n++; - } - for (i=0; its[max].score) - { - max=j; - } - else if (ts[j].score==ts[max].score) - { - if (ts[j].tempsT[0].x=C->heroposition.x; - C->T[0].y=C->heroposition.y; - C->T[0].c=0; - - C->T[1].x=C->heroposition.x+ C->heroposition.w/2; - C->T[1].y=C->heroposition.y; - C->T[1].c=0; - - C->T[2].x=C->heroposition.x + C->heroposition.w; - C->T[2].y=C->heroposition.y; - C->T[2].c=0; - - C->T[3].x=C->heroposition.x+C->heroposition.w; - C->T[3].y=C->heroposition.y + C->heroposition.h /2; - C->T[3].c=0; - - C->T[4].x=C->heroposition.x+C->heroposition.w; - C->T[4].y=C->heroposition.y+C->heroposition.h; - C->T[4].c=0; - - C->T[5].x=C->heroposition.x + C->heroposition.w/2; - C->T[5].y=C->heroposition.y+ C->heroposition.h ; - C->T[5].c=0; - - C->T[6].x=C->heroposition.x; - C->T[6].y=C->heroposition.y+C->heroposition.h; - C->T[6].c=0; - - C->T[7].x=C->heroposition.x; - C->T[7].y=C->heroposition.y+C->heroposition.h/2; - C->T[7].c=0; - - -} - - -SDL_Color GetPixel(SDL_Surface *p , int x , int y) -{ - SDL_Color color; - Uint32 col=0; - - char * Pos = (char*)p->pixels; - Pos += (p->pitch * y); - Pos += (p->format->BytesPerPixel * x); - memcpy (&col ,Pos, p->format->BytesPerPixel ); - - SDL_GetRGB(col , p->format,&color.r , &color.g,&color.b ); - return color; - -} - -void collision (hero *C , background B ) -{ - SDL_Color color ,color2; - int i=0; - color.r=5; - color.g=5; - color.b=5; - tab(C); - while (i<8) - { - color2=GetPixel(B.img , C->T[i].x+B.pos2.x , C->T[i].y+B.pos2.y ); - if ((color.r>=color2.r)&&(color.g>=color2.g)&&(color.b>=color2.b) ) - { - C->T[i].c = 1; - } - i++; - } -} - - - - - - - - - - - - - - diff --git a/fonction.h b/fonction.h deleted file mode 100755 index 77fd420..0000000 --- a/fonction.h +++ /dev/null @@ -1,104 +0,0 @@ -#ifndef fonction_H -#define fonction_H -#include -#include -#include -#include -#include "text.h" -#include "minimap.h" -#define SCREEN_W 1924 -#define SCREEN_H 720 - -typedef struct -{ - int x; - int y; - int c; -}point; - -struct hero -{ - SDL_Surface * heroright[6]; - SDL_Surface * heroleft[6]; - - SDL_Surface * idleright[5]; - SDL_Surface * idleleft[5]; - - SDL_Surface * jumpright[10]; - SDL_Surface * jumpleft[10]; - - SDL_Surface * fallright[4]; - SDL_Surface * fallleft[4]; - - SDL_Rect heroposition; - int sens; - int frame; - int idle; - int jump; - int fall; - int heroisjumping,gravity,speedup,speeddown,directionjump,ground,herospeed; - double vitesse,acceleration; - point T[8]; -}; -typedef struct hero hero; - - - -typedef struct -{ - SDL_Rect pos1; - SDL_Rect pos2; - SDL_Surface *img; -}background; - -Mix_Music* initsound (); - -typedef struct -{ - int score; - int temps; - char playername[20]; -}scoreinfo; - -void init_hero(hero* h,int choix); -void blit_hero( hero* h,SDL_Surface *screen); - -void animation (hero* h,int choix); -void idle(hero* h); -void fall(hero* h); -void jumpanimation(hero* h); - -void Free_hero(hero* h); - -void jump(hero* h); -void restart_jump ( hero* h ); - -void deplacer_perso(hero *p,Uint32 dt); -int choix_hero(); - - -void tab(hero *C); - -SDL_Color GetPixel(SDL_Surface *p , int x , int y); -void collision (hero *C , background B ); - - - - -void initBack( background *b,char ch[]); - -void initBack2(background *b,char ch[]); -void initBut (background *score,char ch[]); - -void scrolling (background * b, int direction , Uint32 dt , hero *p ); -void afficher(background b,SDL_Surface *screen); -void savescore(scoreinfo xs,char *ch); -void bestscore(char *ch,scoreinfo ts[],Text t2,SDL_Surface *screen); - -void liberer( background b); - - - - - -#endif diff --git a/fonction.o b/fonction.o deleted file mode 100644 index 7f77a24..0000000 Binary files a/fonction.o and /dev/null differ diff --git a/AbrilFatface-Regular.ttf b/font/AbrilFatface-Regular.ttf similarity index 100% rename from AbrilFatface-Regular.ttf rename to font/AbrilFatface-Regular.ttf diff --git a/CyberfontBlack-jEVvv.ttf b/font/CyberfontBlack-jEVvv.ttf similarity index 100% rename from CyberfontBlack-jEVvv.ttf rename to font/CyberfontBlack-jEVvv.ttf diff --git a/font/CyberwayRiders-lg97d.ttf b/font/CyberwayRiders-lg97d.ttf new file mode 100755 index 0000000..105f5b7 Binary files /dev/null and b/font/CyberwayRiders-lg97d.ttf differ diff --git a/font/Montserrat-SemiBold.otf b/font/Montserrat-SemiBold.otf new file mode 100755 index 0000000..4fa8281 Binary files /dev/null and b/font/Montserrat-SemiBold.otf differ diff --git a/images/afk2.png b/images/afk2.png deleted file mode 100755 index 07ffd8a..0000000 Binary files a/images/afk2.png and /dev/null differ diff --git a/images/afk3.png b/images/afk3.png deleted file mode 100755 index 25ed4de..0000000 Binary files a/images/afk3.png and /dev/null differ diff --git a/images/afk4.png b/images/afk4.png deleted file mode 100755 index 7eabed5..0000000 Binary files a/images/afk4.png and /dev/null differ diff --git a/images/afk5.png b/images/afk5.png deleted file mode 100755 index ff2d8ce..0000000 Binary files a/images/afk5.png and /dev/null differ diff --git a/images/afkleft2.png b/images/afkleft2.png deleted file mode 100755 index a8b8e95..0000000 Binary files a/images/afkleft2.png and /dev/null differ diff --git a/images/afkleft3.png b/images/afkleft3.png deleted file mode 100755 index 2525f46..0000000 Binary files a/images/afkleft3.png and /dev/null differ diff --git a/images/afkleft4.png b/images/afkleft4.png deleted file mode 100755 index 7b207bc..0000000 Binary files a/images/afkleft4.png and /dev/null differ diff --git a/images/afkleft5.png b/images/afkleft5.png deleted file mode 100755 index 6be9df0..0000000 Binary files a/images/afkleft5.png and /dev/null differ diff --git a/images/bg.png b/images/bg.png deleted file mode 100755 index 46352ef..0000000 Binary files a/images/bg.png and /dev/null differ diff --git a/images/dot.png b/images/dot.png deleted file mode 100755 index e9fc942..0000000 Binary files a/images/dot.png and /dev/null differ diff --git a/images/ezgif.com-resize.png b/images/ezgif.com-resize.png deleted file mode 100755 index f9d46d1..0000000 Binary files a/images/ezgif.com-resize.png and /dev/null differ diff --git a/images/jl1.png b/images/jl1.png deleted file mode 100755 index eb8d5de..0000000 Binary files a/images/jl1.png and /dev/null differ diff --git a/images/jl10.png b/images/jl10.png deleted file mode 100755 index f7f7044..0000000 Binary files a/images/jl10.png and /dev/null differ diff --git a/images/jl11.png b/images/jl11.png deleted file mode 100755 index 3b29410..0000000 Binary files a/images/jl11.png and /dev/null differ diff --git a/images/jl12.png b/images/jl12.png deleted file mode 100755 index b219350..0000000 Binary files a/images/jl12.png and /dev/null differ diff --git a/images/jl13.png b/images/jl13.png deleted file mode 100755 index ef08aae..0000000 Binary files a/images/jl13.png and /dev/null differ diff --git a/images/jl14.png b/images/jl14.png deleted file mode 100755 index a675e71..0000000 Binary files a/images/jl14.png and /dev/null differ diff --git a/images/jl2.png b/images/jl2.png deleted file mode 100755 index fb2d7ea..0000000 Binary files a/images/jl2.png and /dev/null differ diff --git a/images/jl3.png b/images/jl3.png deleted file mode 100755 index 83ef576..0000000 Binary files a/images/jl3.png and /dev/null differ diff --git a/images/jl4.png b/images/jl4.png deleted file mode 100755 index c1fb9a8..0000000 Binary files a/images/jl4.png and /dev/null differ diff --git a/images/jl5.png b/images/jl5.png deleted file mode 100755 index dec53b4..0000000 Binary files a/images/jl5.png and /dev/null differ diff --git a/images/jl6.png b/images/jl6.png deleted file mode 100755 index 1773fbc..0000000 Binary files a/images/jl6.png and /dev/null differ diff --git a/images/jl7.png b/images/jl7.png deleted file mode 100755 index 5edbf91..0000000 Binary files a/images/jl7.png and /dev/null differ diff --git a/images/jl8.png b/images/jl8.png deleted file mode 100755 index b39ec1c..0000000 Binary files a/images/jl8.png and /dev/null differ diff --git a/images/jl9.png b/images/jl9.png deleted file mode 100755 index c603787..0000000 Binary files a/images/jl9.png and /dev/null differ diff --git a/images/jr1.png b/images/jr1.png deleted file mode 100755 index 404b426..0000000 Binary files a/images/jr1.png and /dev/null differ diff --git a/images/jr10.png b/images/jr10.png deleted file mode 100755 index 57725d7..0000000 Binary files a/images/jr10.png and /dev/null differ diff --git a/images/jr11.png b/images/jr11.png deleted file mode 100755 index 459d829..0000000 Binary files a/images/jr11.png and /dev/null differ diff --git a/images/jr12.png b/images/jr12.png deleted file mode 100755 index 1b4bb90..0000000 Binary files a/images/jr12.png and /dev/null differ diff --git a/images/jr13.png b/images/jr13.png deleted file mode 100755 index 7fd7494..0000000 Binary files a/images/jr13.png and /dev/null differ diff --git a/images/jr14.png b/images/jr14.png deleted file mode 100755 index 758f569..0000000 Binary files a/images/jr14.png and /dev/null differ diff --git a/images/jr2.png b/images/jr2.png deleted file mode 100755 index daf796e..0000000 Binary files a/images/jr2.png and /dev/null differ diff --git a/images/jr3.png b/images/jr3.png deleted file mode 100755 index 827d269..0000000 Binary files a/images/jr3.png and /dev/null differ diff --git a/images/jr4.png b/images/jr4.png deleted file mode 100755 index dc03db6..0000000 Binary files a/images/jr4.png and /dev/null differ diff --git a/images/jr5.png b/images/jr5.png deleted file mode 100755 index 1f7fc7e..0000000 Binary files a/images/jr5.png and /dev/null differ diff --git a/images/jr6.png b/images/jr6.png deleted file mode 100755 index effbb99..0000000 Binary files a/images/jr6.png and /dev/null differ diff --git a/images/jr7.png b/images/jr7.png deleted file mode 100755 index 7df5b9f..0000000 Binary files a/images/jr7.png and /dev/null differ diff --git a/images/jr8.png b/images/jr8.png deleted file mode 100755 index d3f8c5d..0000000 Binary files a/images/jr8.png and /dev/null differ diff --git a/images/jr9.png b/images/jr9.png deleted file mode 100755 index 2284021..0000000 Binary files a/images/jr9.png and /dev/null differ diff --git a/images/pl1.png b/images/pl1.png deleted file mode 100755 index 3c667bc..0000000 Binary files a/images/pl1.png and /dev/null differ diff --git a/images/pl2.png b/images/pl2.png deleted file mode 100755 index f2568b2..0000000 Binary files a/images/pl2.png and /dev/null differ diff --git a/images/pl3.png b/images/pl3.png deleted file mode 100755 index dcbceb5..0000000 Binary files a/images/pl3.png and /dev/null differ diff --git a/images/pl4.png b/images/pl4.png deleted file mode 100755 index d3eb516..0000000 Binary files a/images/pl4.png and /dev/null differ diff --git a/images/pl5.png b/images/pl5.png deleted file mode 100755 index 1c55ac1..0000000 Binary files a/images/pl5.png and /dev/null differ diff --git a/images/pl6.png b/images/pl6.png deleted file mode 100755 index 1d7b4cb..0000000 Binary files a/images/pl6.png and /dev/null differ diff --git a/images/pl7.png b/images/pl7.png deleted file mode 100755 index 166f345..0000000 Binary files a/images/pl7.png and /dev/null differ diff --git a/images/pr1.png b/images/pr1.png deleted file mode 100755 index 2edb924..0000000 Binary files a/images/pr1.png and /dev/null differ diff --git a/images/pr2.png b/images/pr2.png deleted file mode 100755 index 2e62744..0000000 Binary files a/images/pr2.png and /dev/null differ diff --git a/images/pr3.png b/images/pr3.png deleted file mode 100755 index 7415be7..0000000 Binary files a/images/pr3.png and /dev/null differ diff --git a/images/pr4.png b/images/pr4.png deleted file mode 100755 index b1432bc..0000000 Binary files a/images/pr4.png and /dev/null differ diff --git a/images/pr5.png b/images/pr5.png deleted file mode 100755 index de61ac1..0000000 Binary files a/images/pr5.png and /dev/null differ diff --git a/images/pr6.png b/images/pr6.png deleted file mode 100755 index b84ada1..0000000 Binary files a/images/pr6.png and /dev/null differ diff --git a/images/pr7.png b/images/pr7.png deleted file mode 100755 index 7a8358b..0000000 Binary files a/images/pr7.png and /dev/null differ diff --git a/images/stage1.bmp b/images/stage1.bmp deleted file mode 100755 index 5b56527..0000000 Binary files a/images/stage1.bmp and /dev/null differ diff --git a/images/01.png b/img/01.png similarity index 100% rename from images/01.png rename to img/01.png diff --git a/img/1.bmp b/img/1.bmp new file mode 100755 index 0000000..6d201c4 Binary files /dev/null and b/img/1.bmp differ diff --git a/img/1.png b/img/1.png new file mode 100755 index 0000000..6e42438 Binary files /dev/null and b/img/1.png differ diff --git a/img/100hp.png b/img/100hp.png new file mode 100755 index 0000000..04b0ce9 Binary files /dev/null and b/img/100hp.png differ diff --git a/img/2.png b/img/2.png new file mode 100755 index 0000000..00bfc8c Binary files /dev/null and b/img/2.png differ diff --git a/img/3.png b/img/3.png new file mode 100755 index 0000000..4a2ea54 Binary files /dev/null and b/img/3.png differ diff --git a/img/best scores.png b/img/best scores.png new file mode 100755 index 0000000..dbba492 Binary files /dev/null and b/img/best scores.png differ diff --git a/img/car_level_final.png b/img/car_level_final.png new file mode 100755 index 0000000..66566ad Binary files /dev/null and b/img/car_level_final.png differ diff --git a/img/loading_screen.png b/img/loading_screen.png new file mode 100755 index 0000000..99a1ce0 Binary files /dev/null and b/img/loading_screen.png differ diff --git a/img/neon_plat.png b/img/neon_plat.png new file mode 100755 index 0000000..4528cbc Binary files /dev/null and b/img/neon_plat.png differ diff --git a/images/option_menu_without_buttons.png b/img/option_menu_without_buttons.png similarity index 100% rename from images/option_menu_without_buttons.png rename to img/option_menu_without_buttons.png diff --git a/img/platform.png b/img/platform.png new file mode 100755 index 0000000..612f300 Binary files /dev/null and b/img/platform.png differ diff --git a/images/small_bg.png b/img/small_bg.png similarity index 100% rename from images/small_bg.png rename to img/small_bg.png diff --git a/images/small_game_development.png b/img/small_game_development.png similarity index 100% rename from images/small_game_development.png rename to img/small_game_development.png diff --git a/images/stage1-01.png b/img/stage1-01.png similarity index 100% rename from images/stage1-01.png rename to img/stage1-01.png diff --git a/main.c b/main.c index ea21c68..b42266e 100755 --- a/main.c +++ b/main.c @@ -5,615 +5,222 @@ #include #include #include -#include "fonction.h" +#include "bg.h" #include "text.h" -#include "minimap.h" + + int main(int argc,char *argv[]) { -//variables - TTF_Init(); - SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_INTERVAL , SDL_DEFAULT_REPEAT_INTERVAL ); - SDL_Init( SDL_INIT_VIDEO ) ; - if ( Mix_OpenAudio(44100,MIX_DEFAULT_FORMAT,MIX_DEFAULT_CHANNELS,1024)==-1 ) + TTF_Init(); + SDL_Init( SDL_INIT_VIDEO ) ; + SDL_EnableKeyRepeat(10 , SDL_DEFAULT_REPEAT_INTERVAL ); + SDL_Init(SDL_INIT_EVERYTHING); + if ( Mix_OpenAudio(44100,MIX_DEFAULT_FORMAT,MIX_DEFAULT_CHANNELS,1024)==-1 ) { printf("%s",Mix_GetError() ); } - SDL_Surface *screen =NULL; - background g,d,f,score; - SDL_Init(SDL_INIT_EVERYTHING); - screen=SDL_SetVideoMode(1920,1024, 32,SDL_HWSURFACE| SDL_DOUBLEBUF |SDL_SRCALPHA |SDL_FULLSCREEN); - SDL_WM_SetCaption("game",NULL); - hero h; - int choix = choix_hero(); - init_hero(&h,choix); - SDL_Color couleurblanche = {0, 0, 0}; - int continuer=1; - Uint32 dt,t_prev; - if ( !screen) + SDL_Surface *screen; + background g[24]; + background mask; + background loading; + car C; + image IMAGE_BIRDS; + //background obs1[3]; + screen=SDL_SetVideoMode(1920,1080,32,SDL_HWSURFACE |SDL_SRCALPHA|SDL_FULLSCREEN); + + if ( !screen) { printf("Unable to set 600*300 video : %s\n",SDL_GetError()); return 1; } + SDL_Event event ; Mix_Music *music1; - Mix_Music *music2; - Mix_Music *music3; - background BG[61]; scoreinfo xs; xs.temps=0; xs.score=0; - scoreinfo ts[100]; - int done =0,n1=0,n2=0,n3=0; - int niveau = 1,ba1=0,po=0,r=0,z=0; - int direction=0; - int x1=0; - int x=0; - int y=0; - int i=20; - int startime=-1; + int done=0,n1=0; + int niveau = 1; + int ba=0; + int direction=1; + int i=0,j=0,f=0; char mscore[1000]; - char chi[100]; - char ch1[100]; - char ch2[100]; - char ch3[100]; - char chx[9999]; char* ch = "score.txt"; Text t,t2; atexit(SDL_Quit); + mask.img = SDL_LoadBMP ("img/1.bmp"); + if (mask.img==NULL) + printf("erreur %s",SDL_GetError()); - //music - music2=initsound("Dark Souls Boss Fight Meme Template Why do I hear Boss Music Template.mp3"); - music1=initsound("rizz.mp3"); - music3=initsound("bgm1.mp3"); - - //background and text - initBack (&d ,"images/bg.png"); - initBack2 (&g ,"images/stage1.bmp"); - initBack (&f ,"images/small_game_development.png"); - initBut (&score,"01.png"); - initText(&t); - initText2(&t2); - - - - while(continuer == 1) - { - t_prev = SDL_GetTicks(); - - switch (niveau) - { - case 1 : - { - afficher(g,screen); - afficher (score,screen); - displaytext(t,screen,mscore); - blit_hero(&h,screen); - //SDL_Flip(screen); - SDL_Delay(10); - collision (&h,g); - if (h.T[3].c==1) - printf ("\nd"); - else - printf("\nnd"); - if (n1==0) - { - Mix_PlayMusic(music1,-1); - n1++; - } - - SDL_PollEvent(&event); - switch (event.type) - { - case SDL_QUIT : - continuer =0; - break; - case SDL_KEYDOWN: - { - switch(event.key.keysym.sym) - { - case SDLK_ESCAPE: - { - continuer=0; - break; - } - case SDLK_a : - { - niveau=2; - n1=0; - } - break; - case SDLK_RIGHT : - { - h.sens =0; - direction=1; - } - break; - case SDLK_LEFT : - { - h.sens =1; - direction=2; - } - break; - case SDLK_SPACE : - { - h.heroisjumping = 1; - if (h.heroisjumping == 1 ) - { - h.sens=3; - jumpanimation(&h); - direction=3; - } - } - break; - case SDLK_LSHIFT : - { - if ( h.acceleration < 0.100 ) - { - h.acceleration+=0.055; - } - } - break; - default: - { - if(h.sens==0) - { - h.sens=-1; - idle(&h); - } - else if(h.sens==1) - { - h.sens=-2; - idle(&h); - } - }//default key down - break; - }//keydown - break; - case SDL_KEYUP: - { - switch(event.key.keysym.sym) - { - case SDLK_RIGHT : - { - h.sens=0; - direction=1; - if (h.acceleration >= 0.01 ) - { - animation(&h,choix); - h.acceleration-=0.01; - deplacer_perso(&h,dt); - } - } - break; - case SDLK_LEFT : - { - h.sens=1; - direction=2; - if (h.acceleration >= 0.01 ) - { - animation(&h,choix); - h.acceleration-=0.01; - deplacer_perso(&h,dt); - } - } - break; - case SDLK_LSHIFT : - { - if ( h.acceleration >= 0.010 ) - { - h.acceleration-=0.005; - deplacer_perso(&h,dt); - animation(&h,choix); - } - } - break; - }//switch keyup - }//keyup - }//event type - break; - case SDL_MOUSEBUTTONDOWN : - { - if ( event.motion.x>=score.pos1.x && event.motion.x<=score.pos1.x+(score.pos2.w ) && event.motion.y>=score.pos1.y && event.motion.y<=score.pos1.y+score.pos2.h ) - { - ba1=1; - } - } - }//mouse buttondown - xs.temps=SDL_GetTicks()-startime; - - - if (direction==1) - { - if (startime==-1) - { - startime=SDL_GetTicks(); - } - xs.score++; - sprintf(mscore, "score : %d", xs.score); - if(g.pos2.x==2000) - { - savescore(xs,ch); - } - if (g.pos2.x==0) - { - xs.score=0; - xs.temps=0; - } - }//direction - if (ba1==1) - { - bestscore(ch,ts,t2,screen); - }//score - scrolling (&g,direction,dt,&h); - SDL_Flip(screen); - }//case 1 - break; - case 2 : + music1=initsound("sound/result.mp3"); + initialiser_imageBIRDS(&IMAGE_BIRDS); + initBack (&loading ,"img/loading_screen.png"); + afficher(loading,screen); + SDL_Flip(screen); + //initobs1(&obs1,"img/1.png"); + initAnime(g,"animebg/",".png",24,0,0,1920,1080); + initAnime2(C.b,"car animation/",".png",12,10,730); + //initAnime2(obs1,"car animation/",".png",12,10,730); + //initAnime2(obs1,"car animation/",".png",12,10,730); + mask .pos1.x=0; + mask .pos1.w=0; + mask.pos1.w=mask.img->w; + mask.pos1.h=mask.img->h; + mask.pos2.x=0; + mask.pos2.y=0; + mask.pos2.w=mask.img->w; + mask.pos2.h=mask.img->h; + initText(&t); +while ( !done) +{ + switch (niveau) { - afficher(d,screen); - afficher (score,screen); - displaytext(t,screen,mscore); - if (n2==0) - { - Mix_PlayMusic(music2,-1); - n2++; - } - SDL_PollEvent(&event); - switch (event.type) - { - case SDL_QUIT : - continuer =0; - break; - case SDL_KEYDOWN: - { - switch(event.key.keysym.sym) - { - case SDLK_ESCAPE: - { - continuer=0; - } - break; - case SDLK_a : - { - niveau=3; - n2=0; - } - break; - case SDLK_RIGHT : - { - h.sens =0; - direction=1; - } - break; - case SDLK_LEFT : - { - h.sens =1; - direction=2; - } - break; - case SDLK_SPACE : - { - h.heroisjumping = 1; - if (h.heroisjumping == 1 ) - { - h.sens=3; - jumpanimation(&h); - direction=3; - } - } - break; - case SDLK_LSHIFT : - { - if ( h.acceleration < 0.100 ) - { - h.acceleration+=0.055; - } - } - break; - default: - { - if(h.sens==0) - { - h.sens=-1; - idle(&h); - } - else if(h.sens==1) - { - h.sens=-2; - idle(&h); - } - }//default key down - break; - }//keydown - break; - } - case SDL_KEYUP: - { - switch(event.key.keysym.sym) - { - case SDLK_RIGHT : - { - h.sens=0; - direction=1; - if (h.acceleration >= 0.01 ) - { - animation(&h,choix); - h.acceleration-=0.01; - deplacer_perso(&h,dt); - } - } - break; - case SDLK_LEFT : - { - h.sens=1; - direction=2; - if (h.acceleration >= 0.01 ) - { - animation(&h,choix); - h.acceleration-=0.01; - deplacer_perso(&h,dt); - } - } - break; - case SDLK_LSHIFT : - { - if ( h.acceleration >= 0.010 ) - { - h.acceleration-=0.005; - deplacer_perso(&h,dt); - animation(&h,choix); - } - } - break; - }//switch keyup - }//keyup - break; - case SDL_MOUSEBUTTONDOWN : - { - if ( event.motion.x>=score.pos1.x && event.motion.x<=score.pos1.x+(score.pos2.w ) && event.motion.y>=score.pos1.y && event.motion.y<=score.pos1.y+score.pos2.h ) - { - ba1=1; - } - }//mouse buttondown - }//event type - - - xs.temps=SDL_GetTicks()-startime; - if (direction==1) - { - if (startime==-1) - { - startime=SDL_GetTicks(); - } - xs.score++; - sprintf(mscore, "score : %d", xs.score); - if(d.pos2.x==2000) - { - savescore(xs,ch); - } - if (d.pos2.x==0) - { - xs.score=0; - xs.temps=0; - } - }//direction - if (ba1==1) - { - bestscore(ch,ts,t2,screen); - }//score - scrolling (&d,direction,dt,&h); + case 1 : + //afficher(g,screen); + //SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 255, 255, 255)); + playAnime(g,screen,24,&f); + playAnime(C.b,screen,12,&i); + displaytext(t,screen,mscore); + afficher_imageBIRDS(screen, IMAGE_BIRDS); - }//case 2 - break; - case 3 : - { - afficher(f,screen); - afficher (score,screen); - displaytext(t,screen,mscore); - n1++; - SDL_PollEvent(&event); - switch (event.type) - { - case SDL_QUIT : - continuer =0; - break; - case SDL_KEYDOWN: - { - switch(event.key.keysym.sym) - { - case SDLK_ESCAPE: - { - continuer=0; - break; - } - case SDLK_a : - { - niveau=1; - n1=0; - } - break; - case SDLK_RIGHT : - { - h.sens =0; - direction=1; - } - break; - case SDLK_LEFT : - { - h.sens =1; - direction=2; - } - break; - case SDLK_SPACE : - { - h.heroisjumping = 1; - if (h.heroisjumping == 1 ) - { - h.sens=3; - jumpanimation(&h); - direction=3; - } - } - break; - case SDLK_LSHIFT : - { - if ( h.acceleration < 0.100 ) - { - h.acceleration+=0.055; - } - } - break; - default: - { - if(h.sens==0) - { - h.sens=-1; - idle(&h); - } - else if(h.sens==1) - { - h.sens=-2; - idle(&h); - } - }//default key down - break; + + if (n1==0){ + Mix_PlayMusic(music1,-1); + printf("%s",Mix_GetError()); } - }//keydown - break; - case SDL_KEYUP: - { - switch(event.key.keysym.sym) - { - case SDLK_RIGHT : + n1++; + while (SDL_PollEvent (&event) ) { - h.sens=0; - direction=1; - if (h.acceleration >= 0.01 ) + switch (event.type) + { + case SDL_QUIT : + done =1; + break; + case SDL_KEYDOWN : + switch(event.key.keysym.sym) + { + case SDL_QUIT: + { + done=1; + } + break; + case SDLK_ESCAPE: + { + done=1; + } + break; + case SDLK_UP: + { + ba=3; + } + break; + case SDLK_DOWN: + { + ba=4; + } + break; + default: + { + ba=0; + } + break; + } + + case SDL_KEYUP: + switch(event.key.keysym.sym) + { + case SDL_QUIT: + { + done=1; + } + break; + case SDLK_ESCAPE: + { + done=1; + } + break; + case SDLK_UP: + { + ba=3; + } + break; + case SDLK_DOWN: + { + ba=4; + } + break; + default: + { + ba=0; + } + break; + } + } + } + collision (&C ,mask ,&done ); + if (!done) + { + xs.score=xs.score+6; + sprintf(mscore, "score : %d", xs.score); + } + for (j=0;j<24;j++) + { + if ( (C.T[1].c==1)|| (C.T[3].c==1) ||(C.T[5].c==1) ) { - animation(&h,choix); - h.acceleration-=0.01; - deplacer_perso(&h,dt); + g[j].pos2.x=0; } + + } - break; - case SDLK_LEFT : + if ( (C.T[1].c==1)|| (C.T[3].c==1) ||(C.T[5].c==1) ) { - h.sens=1; - direction=2; - if (h.acceleration >= 0.01 ) - { - animation(&h,choix); - h.acceleration-=0.01; - deplacer_perso(&h,dt); - } + mask.pos2.x=0; } - break; - case SDLK_LSHIFT : + for (j=0;j<24;j++) { - if ( h.acceleration >= 0.010 ) + + if (g[j].pos2.x==0) { - h.acceleration-=0.005; - deplacer_perso(&h,dt); - animation(&h,choix); + xs.score=0; + xs.temps=0; } + } + + + + + //scrolling (&g,1); + //collision (&C ,mask ,&done ); + scrolling (&mask,1); + scrollinganime (g,1); + caranim(C.b,ba); + ba=0; + SDL_Flip(screen); + + + + break; - }//switch keyup - }//keyup - break; - case SDL_MOUSEBUTTONDOWN : - { - if ( event.motion.x>=score.pos1.x && event.motion.x<=score.pos1.x+(score.pos2.w ) && event.motion.y>=score.pos1.y && event.motion.y<=score.pos1.y+score.pos2.h ) - { - ba1=1; - } - }//mouse buttondown - }//event type - - xs.temps=SDL_GetTicks()-startime; - if (direction==1) - { - if (startime==-1) - { - startime=SDL_GetTicks(); - } - xs.score++; - sprintf(mscore, "score : %d", xs.score); - if(f.pos2.x==2000) - { - savescore(xs,ch); - } - if (f.pos2.x==0) - { - xs.score=0; - xs.temps=0; - } - }//direction - if (ba1==1) - { - bestscore(ch,ts,t2,screen); - }//score - scrolling (&f,direction,dt,&h); - SDL_Flip(screen); - }//case 3 - break; - }//switch - -//update - if( h.sens == 0 && direction==1) - { - scrolling (&g,direction,dt,&h); - animation(&h,choix); - deplacer_perso(&h,dt); - } - else if (h.sens ==1 && direction==2) - { - scrolling (&g,direction,dt,&h); - animation(&h,choix); - deplacer_perso(&h,dt); - } - jump(&h); - if (h.heroisjumping == 1 && h.sens==0) - { - h.sens=3; - jumpanimation(&h); - } - else if (h.heroisjumping == 1 && h.sens==1) - { - h.sens=-3; - jumpanimation(&h); - } - //printf("%.3f \n", h.acceleration); - dt = SDL_GetTicks()-t_prev; - } - Mix_FreeMusic (music1); - Mix_FreeMusic (music2); - Mix_FreeMusic (music3); - liberer (g); - liberer (d); - liberer (f); - liberer (score); - freeText(t); - Free_hero(&h); - SDL_Quit(); - return EXIT_SUCCESS ; + } - - - - - - - - - - - - +} +Mix_FreeMusic (music1); +freeAnime(g,24); +freeAnime(C.b,12); +TTF_CloseFont (t.font); +SDL_FreeSurface(mask.img); +SDL_FreeSurface(loading.img); +SDL_Quit(); +TTF_Quit(); +return 0; +} + - - + + + diff --git a/main.o b/main.o index e8d7c5b..85fad91 100644 Binary files a/main.o and b/main.o differ diff --git a/makefile b/makefile index bfc6268..b9de01e 100755 --- a/makefile +++ b/makefile @@ -1,12 +1,10 @@ -prog : main.o fonction.o text.o minimap.o - gcc fonction.o main.o text.o minimap.o -o prog -lSDL -lSDL_image -lSDL_ttf -lSDL_mixer -g +prog : main.o bg.o text.o + gcc bg.o main.o text.o -o prog -lSDL -lSDL_image -lSDL_ttf -lSDL_mixer -g -fonction.o : fonction.c - gcc -c fonction.c -g +bg.o : bg.c + gcc -c bg.c -g main.o : main.c gcc -c main.c -g -text.o : text.c - gcc -c text.c -g -minimap.o : minimap.c - gcc -c minimap.c -g +texte.o : text.c + gcc -c text.c -g diff --git a/minimap.c b/minimap.c deleted file mode 100644 index e75b045..0000000 --- a/minimap.c +++ /dev/null @@ -1,95 +0,0 @@ -#include "minimap.h" - -void initMinimap (minimap *M) -{ - init (&M->b); - initdot(&M->dot); -} - -void init (image *M ) -{ - M->img = IMG_Load ("images/ezgif.com-resize.png"); - M->pos1.x=0; - M->pos1.y=0; - M->pos2.x=0; - M->pos2.y=0; - M->pos2.w=M->img->w; - M->pos2.h = M->img->h; -} - -void initback (image *B) -{ - B->img = SDL_LoadBMP ("images/stage1.bmp"); - - B->pos1.x=0; - B->pos1.y=0; - B->pos2.x=0; - B->pos2.y=0; - B->pos2.w=B->img->w; - B->pos2.h = B->img->h; -} - -void initC (image *B) -{ - B->img = IMG_Load ("images/back_button.png"); - B->pos1.x=30; - B->pos1.y=350; - B->pos2.x=0; - B->pos2.y=0; - B->pos2.w=B->img->w; - B->pos2.h = B->img->h; -} - -void initdot (image *D) -{ - D->img = IMG_Load ("images/dot.png"); - D->pos2.x=0; - D->pos2.y=0; - D->pos2.w=D->img->w; - D->pos2.h = D->img->h; -} - -void pos (image *D, float px , float py ) -{ - D->pos1.x= px*0.25 ; - D->pos1.y=py*0.25; - -} - - -void initText3( Text *A,int x,int y,int r,int g ,int b ,int n) -{ - A->position.x=x; - A->position.y=y; - A->textColor.r=r; - A->textColor.g=g; - A->textColor.b=b; - A->font=TTF_OpenFont ("AbrilFatface-Regular.ttf",n); -} - - -void afficheT (int t , Text T , SDL_Surface *screen ) -{ - char cht[6] , ch[15]; - sprintf(cht,"%d",t); - strcpy(ch,"temps :"); - strcat (ch , cht); - T.surfaceTexte = TTF_RenderText_Solid (T.font , ch , T.textColor); - SDL_BlitSurface ( T.surfaceTexte , NULL, screen , &T.position ); -} - -/*void freeText( Text A) -{ - SDL_FreeSurface ( A.surfaceTexte ); -}*/ - - -void affichage (image M , SDL_Surface * screen) -{ - SDL_BlitSurface (M.img , &M.pos2 , screen , &M.pos1); -} - -/*void liberer(image M) -{ - SDL_FreeSurface(M.img); -}*/ diff --git a/minimap.h b/minimap.h deleted file mode 100644 index 34deda2..0000000 --- a/minimap.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef Minimap_H -#define Minimap_H -#include -#include -#include -#include "fonction.h" -#include "text.h" -//#define SCREEN_W 1920 -//#define SCREEN_H 950 - - -/*typedef struct -{ - SDL_Rect position; - TTF_Font *font; - SDL_Surface *surfaceTexte; - SDL_Color textColor; - char texte [50]; -}Text ;*/ - -typedef struct -{ - SDL_Rect pos1; - SDL_Rect pos2; - SDL_Surface *img; -}image; - - -typedef struct -{ - image b; - image dot; - -}minimap; - - - -/*typedef struct -{ - image I; - point T[8]; -}perso;*/ - - -void initMinimap (minimap *M); -void init (image *M ); -void initdot (image *D); -void initback (image *B); -void initC (image *B); -void initText3( Text *A,int x,int y,int r,int g ,int b ,int n); - - -void afficheT (int t , Text T , SDL_Surface *screen ); -void pos (image *D, float px , float py ); -void affichage (image M , SDL_Surface * screen); - - -//void liberer1(image M); - -//void freeText( Text A); - - -#endif diff --git a/minimap.o b/minimap.o deleted file mode 100644 index bcc751d..0000000 Binary files a/minimap.o and /dev/null differ diff --git a/music.png b/music.png new file mode 100755 index 0000000..08af692 Binary files /dev/null and b/music.png differ diff --git a/prog b/prog index 0744bbe..1a056c8 100755 Binary files a/prog and b/prog differ diff --git a/rizz.mp3 b/rizz.mp3 deleted file mode 100755 index d6b2f23..0000000 Binary files a/rizz.mp3 and /dev/null differ diff --git a/score.txt b/score.txt deleted file mode 100755 index 0495f4c..0000000 --- a/score.txt +++ /dev/null @@ -1,8 +0,0 @@ -2001 0 yahya -2006 0 samir -2004 17244 anis -2009 16 ramzi -2009 15 zikou -2001 15 souhaib -2000 18 yassin -2000 18 lol diff --git a/sound/result.mp3 b/sound/result.mp3 new file mode 100755 index 0000000..2613ceb Binary files /dev/null and b/sound/result.mp3 differ diff --git a/text.c b/text.c index bd72f58..10c0ddb 100755 --- a/text.c +++ b/text.c @@ -8,22 +8,23 @@ void initText( Text *A) { A->position.x=10; A->position.y=10; - A->textColor.r=0; - A->textColor.g=0; - A->textColor.b=0; - A->font=TTF_OpenFont ("AbrilFatface-Regular.ttf",40); + A->textColor.r=255; + A->textColor.g=255; + A->textColor.b=255; + A->font=TTF_OpenFont ("font/CyberwayRiders-lg97d.ttf",70); + } void initText2( Text *A) { A->position.x=10; A->position.y=350; A->textColor.r=255; - A->textColor.g=0; - A->textColor.b=0; - A->font=TTF_OpenFont ("AbrilFatface-Regular.ttf",40); + A->textColor.g=255; + A->textColor.b=255; + A->font=TTF_OpenFont ("font/Montserrat-SemiBold.otf",40); } -void posT(Text *A,int x,int y) +void pos(Text *A,int x,int y) { A->position.x=x; A->position.y=y; diff --git a/text.h b/text.h index f64df45..5912d82 100755 --- a/text.h +++ b/text.h @@ -15,7 +15,7 @@ typedef struct void initText( Text *t); void initText2( Text *t); -void posT(Text *A,int x,int y); +void pos(Text *A,int x,int y); void freeText(Text A); void displaytext( Text t,SDL_Surface *screen , char ch []); #endif diff --git a/text.o b/text.o index 36784ea..60d884c 100644 Binary files a/text.o and b/text.o differ