begin process at 2012 02 05 03:52:35
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Jeux

 > PAC_MAN

PAC_MAN


 Information sur la source

Note :
9,33 / 10 - par 3 personnes
9,33 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :Jeux Classé sous :jeu, pacman, turboc Niveau :Initié Date de création :14/06/2005 Date de mise à jour :15/06/2005 20:14:50 Vu / téléchargé :8 938 / 798

Auteur : xmenneo2003

Ecrire un message privé
Commentaire sur cette source (11)
Ajouter un commentaire et/ou une note

 Description

Ce programme est la version finale de mon premier programme en Turbo_C++ en utilisant la programmtion orienté objet
un jeu tres amusant plein e surprise , il comporte 03 stages , et il y a plein de commentaire pour bin comprendre,
j'ai ajouter une bibliotheque pour charger des photos bmp sous dos , tres facile a utiliser .  

Source

  • #include"stage.h"
  • #include<time.h>
  • #include <fcntl.h>
  • #include <io.h>
  • #define ESC 0X1B
  • #define CR 0XD
  • #define HAUT 0X48
  • #define BAS 0X50
  • #define DROIT 0X4D
  • #define GAUCH 0X4B
  • #define pi 3.1429654
  • #define SUP 529
  • #define INF 123
  • #define lin 130
  • #define col 20
  • int vrai=1;
  • int bbb=1;
  • int mm=100;
  • //t_screen sDisplay;
  • t_image v,v1,v2,v3,v4,v5,v6,v7,v8,v9,v10,v11,v12,v13,v14,v15,v16,v17,v18,v19,v20,v21,v22,v23,v24;
  • class Pacman;
  • class Virus;
  • class BIG_FOTHER
  • {
  • public :
  • BIG_FOTHER(int,int,int);
  • friend void Score();
  • friend void demo_music_laser();
  • void SPE_M(int s);
  • void Modifier(int,int);
  • int lecS(){return speed;}
  • int lecX(){return x;}
  • int lecY(){return y;}
  • protected :
  • int x,y,c,speed;
  • };
  • class Virus:public BIG_FOTHER
  • {
  • public :
  • Virus(int,int,int);
  • void Affiche(int);
  • void Cache();
  • void Command(Pacman,int);
  • void Command2(Pacman,int);
  • void Command3(Pacman,int);
  • friend void Getout(Virus&,Virus&,Virus&,Virus&);
  • void Up();
  • void Lf();
  • void Rg();
  • void REMISE_0();
  • void Restore2();
  • void Restore3();
  • void Restore4();
  • void Restore5();
  • private :
  • int bool,spool;
  • };
  • class Pacman:public BIG_FOTHER
  • { public:
  • Pacman(int,int,int,int vie);
  • void Affiche1(char);
  • void Cache1();
  • void Life(int);
  • void Add();
  • void vieADD();
  • void vieSUB();
  • void SUB();
  • void Restore();
  • void Compteur();
  • void Pomme();
  • void Banane();
  • void Raisin();
  • int lec_cpt(){return cpt;}
  • int lec_pom(){return pom;}
  • int lec_ban(){return ban;}
  • int lec_rai(){return rai;}
  • void Play();
  • void REMISE_0();
  • int lecCPT(){return cpt;}
  • void Modifier_cpt(int);
  • int lecVie(){return vie;}
  • friend void Command1(Pacman&,Virus,Virus,Virus,Virus);
  • private:
  • int vie,ban,rai,pom,cpt;
  • };
  • //----------------------------------- constructeur big_fother -------------
  • BIG_FOTHER::BIG_FOTHER(int x1,int y1,int c1)
  • {
  • x=x1;
  • y=y1;
  • c=c1;
  • speed=80;
  • }
  • //-------------------------------------------------------------------------
  • void BIG_FOTHER::SPE_M(int s)
  • {
  • speed=s;
  • }
  • //----------------------------------- constructeur virus--------------------
  • Virus::Virus(int x1,int y1,int c1):BIG_FOTHER(x1,y1,c1)
  • {
  • spool=0;
  • bool=0;
  • }
  • //----------------------------------- constructeur pacman--------------------
  • Pacman::Pacman(int a,int b,int c1,int v1):BIG_FOTHER(a,b,c1)
  • {
  • ban=0;
  • rai=0;
  • pom=0;
  • vie=v1;
  • cpt=0;
  • }
  • //-------------------------------------------------------------------------
  • void Pacman::REMISE_0()
  • {
  • ban=0;
  • rai=0;
  • pom=0;
  • vie=2;
  • cpt=0;
  • vrai=1;
  • }
  • //-----------------------------------------------------------------------
  • void Virus::REMISE_0()
  • {
  • spool=0;
  • bool=0;
  • }
  • //----------------------------------- partie sonor--------------------------
  • void demo_music_laser()
  • {
  • for(int count=0;count<10;count++)
  • {sound(count*100);delay(10);}
  • nosound();
  • }
  • //..........................................................................
  • void demo_music_ambilance()
  • {
  • for(int count=0;count<2;count++)
  • {sound(4000);delay(5);sound(7000);delay(5);}
  • nosound();
  • }
  • //------------------------------------ les methodes de big_fother------------
  • void BIG_FOTHER::Modifier(int x1,int y1)
  • {
  • x=(x+x1) ;
  • y=(y+y1) ;
  • }
  • //----------------------------------- les methodes de pacman----------------
  • void Pacman::Compteur()
  • {
  • cpt+=1;
  • gotoxy(12,3);printf("%d",cpt);
  • sound(7000);
  • delay(50);
  • nosound();
  • }
  • //.........................................................................
  • void Pacman::Pomme()
  • {
  • pom+=20;
  • gotoxy(12,13);printf("%d",pom);
  • sound(5000);
  • delay(50);
  • nosound();
  • }
  • //........................................................................
  • void Pacman::Banane()
  • {
  • ban+=50;
  • gotoxy(12,15);printf("%d",ban);
  • sound(5000);
  • delay(50);
  • nosound();
  • }
  • //........................................................................
  • void Pacman::Raisin()
  • {
  • rai+=100;
  • gotoxy(12,17);printf("%d",rai);
  • sound(7000);
  • delay(50);
  • nosound();
  • }
  • //.......................................................................
  • void Pacman::vieADD()
  • {
  • vie+=1;
  • }
  • //........................................................................
  • void Pacman::vieSUB()
  • {
  • vie=vie-1;
  • }
  • //........................................................................
  • void Pacman::Add()
  • {
  • DisplayImage(&sDisplay, &v4,10+20*vie,120,0);
  • sound(7000);
  • delay(50);
  • nosound();
  • }
  • //.........................................................................
  • void Pacman::SUB()
  • {
  • DisplayImage(&sDisplay, &v5,10+20*vie,120,0);
  • }
  • //.........................................................................
  • void Pacman::Affiche1(char n)
  • {
  • SetPalette(&sDisplay, &v.ihHeader);
  • setcolor(15);
  • setfillstyle(1,15);
  • switch(n)
  • {
  • case DROIT :pieslice(lecX()+7,lecY()+7,0,360,5);delay(20);DisplayImage(&sDisplay, &v7,lecX(),lecY(),0);break;
  • case HAUT :pieslice(lecX()+7,lecY()+7,0,360,5);delay(20);DisplayImage(&sDisplay, &v9,lecX(),lecY(),0);break;
  • case BAS :pieslice(lecX()+7,lecY()+7,0,360,5);delay(20);DisplayImage(&sDisplay, &v10,lecX(),lecY(),0);break;
  • case GAUCH :pieslice(lecX()+7,lecY()+7,0,360,5);delay(20);DisplayImage(&sDisplay, &v8,lecX(),lecY(),0);break;
  • }
  • }
  • //..........................................................................
  • void Pacman::Life(int n)
  • {
  • int ii,jj;
  • setfillstyle(1,4);
  • randomize();
  • ii=rand() % 30;
  • jj=rand() % 30;
  • if (getpixel(14*ii+lin+21+7,14*jj+col+21+7)!=12)
  • if (( 14*ii+lin+21 < 500)&&(14*jj+col+21 < 400))
  • { if (n==1){DisplayImage(&sDisplay, &v4,14*ii+lin+21,14*jj+col+21,0); }
  • if (n==2){DisplayImage(&sDisplay, &v15,14*ii+lin+21,14*jj+col+21,0); }
  • if (n==3){DisplayImage(&sDisplay, &v16,14*ii+lin+21,14*jj+col+21,0); }
  • if (n==4){DisplayImage(&sDisplay, &v17,14*ii+lin+21,14*jj+col+21,0); }
  • }
  • }
  • //..........................................................................
  • void Pacman::Cache1()
  • {
  • DisplayImage(&sDisplay, &v5,lecX(),lecY(),0);
  • }
  • //------------------------------- les methodes de virus---------------------
  • void Virus::Affiche(int n)
  • {
  • SetPalette(&sDisplay, &v.ihHeader);
  • bool=0;
  • spool=0;
  • if(getpixel(x+7,y+7)==2) bool=1;
  • if(getpixel(x+7,y+7)==15) spool=1;
  • if (bbb)
  • {
  • if (c==4) {DisplayImage(&sDisplay, &v,x,y,0); }
  • if (c==9) {DisplayImage(&sDisplay, &v1,x,y,0); }
  • if (c==14) {DisplayImage(&sDisplay, &v2,x,y,0); }
  • if (c==1) {DisplayImage(&sDisplay, &v6,x,y,0); }
  • if (c==13) {DisplayImage(&sDisplay, &v7,x,y,0); }
  • setcolor(0);
  • setfillstyle(1,0);
  • switch(n)
  • {
  • case 0: pieslice(x+7,y+4,0,360,1);
  • pieslice(x+12,y+4,0,360,1);
  • break;
  • case 1: pieslice(x+4,y+4,0,360,1);
  • pieslice(x+8,y+4,0,360,1);
  • break;
  • case 2: pieslice(x+5,y+6,0,360,1);
  • pieslice(x+10,y+6,0,360,1);
  • break;
  • case 3: pieslice(x+5,y+2,0,360,1);
  • pieslice(x+10,y+2,0,360,1);
  • break;
  • }
  • }
  • else DisplayImage(&sDisplay, &v18,x,y,0); //image de la peur v18
  • }
  • //.........................................................................
  • void Virus::Cache()
  • {
  • DisplayImage(&sDisplay, &v5,x,y,0);
  • if (bool) { setcolor(2);setfillstyle(SOLID_FILL,2);pieslice(x+7,y+7,0,360,1);}
  • //if (spool) { setcolor(15);setfillstyle(SOLID_FILL,15);pieslice(x+7,y+7,0,360,3);}
  • }
  • //.........................................................................
  • void Virus::Command(Pacman p,int n)
  • {
  • int choix;
  • if (( x != p.lecX() ) || ( y != p.lecY() ))
  • {if (x != p.lecX())
  • {if (x < p.lecX()) {if ((getpixel(x+7+15,y+7)!=12)) choix=0;else if (getpixel(x+7,y-15+7)!=12) choix=3;}
  • else {if ((getpixel(x-15+7,y+7)!=12)) choix=1;else if(getpixel(x+7,y+7-15)!=12) choix=2;}}
  • else
  • {if (y < p.lecY()) {if(getpixel(x+7,y+15+7)!=12) choix=2;else if (getpixel(x+15+7,y+7)!=12) choix=0;}
  • else {if (getpixel(x+7,y-15+7)!=12) choix=3;else if (getpixel(x-15+7,y+7)!=12) choix=1;}}
  • for (int l=1;l<=n;l++)
  • {
  • if (vrai){
  • switch(choix) {
  • case 0: Cache();x+=14;Affiche(0);
  • break;
  • case 1 : Cache();x-=14;Affiche(1);
  • break;
  • case 2 : Cache();y+=14;Affiche(2);
  • break;
  • case 3 : Cache();y-=14;Affiche(3);
  • break;
  • }
  • delay(speed/10);
  • }
  • }
  • }
  • else {vrai=0;Cache();delay(100);demo_music_laser();}
  • }
  • //........................................................................
  • void Virus::Command3(Pacman p,int n)
  • {
  • int choix;
  • randomize();
  • int non=1;
  • while(non)
  • {
  • choix=rand()%4;
  • switch(choix)
  • {
  • case 0:if (getpixel(x+7+15,y+7)!=12) non=0;break;
  • case 1:if(getpixel(x+7-15,y+7)!=12) non=0;break;
  • case 2:if (getpixel(x+7,y+7+15)!=12) non=0;break;
  • // case 3:if (getpixel(x+7,y+7-15)!=12) non=0;break;
  • }
  • }
  • if ( (x!=p.lecX())||(y != p.lecY()) )
  • {
  • for (int l=1;l<=n;l++){
  • if (vrai){
  • switch(choix) {
  • case 0 : Cache();if (x != SUP) x+=14;
  • else if (x==SUP) x=INF;
  • Affiche(0);
  • break;
  • case 1 : Cache();if (x != INF) x-=14;
  • else if (x==INF) x=SUP;
  • Affiche(1);
  • break;
  • case 2 : Cache();y+=14;Affiche(2);
  • break;
  • case 3 : Cache();y-=14;Affiche(3);
  • break;
  • } delay(speed/10);
  • }
  • }
  • }
  • else {vrai=0;Cache();delay(100); demo_music_laser();}
  • }
  • //..........................................................................
  • void Virus::Command2(Pacman p,int n)
  • {
  • int choix;
  • if ( (x!=p.lecX())||(y != p.lecY()) )
  • {if (y != p.lecY())
  • {if (y < p.lecY()) {if ((getpixel(x+7,y+7+15)!=12)) choix=2;else if ((getpixel(x+7-15,y+7)!=12)) choix=1;}
  • else {if ((getpixel(x+7,y+7-15)!=12)) choix=3;else if ((getpixel(x+7+15,y+7)!=12)) choix=0;}}
  • else
  • {if (x < p.lecX()) {if((getpixel(x+15+7,y+7)!=12)) choix=0;else if ((getpixel(x+7,y-15+7)!=12)) choix=3;}
  • else {if ((getpixel(x-15+7,y+7)!=12)) choix=1;else if ((getpixel(x+7,y+7+15)!=12)) choix=2;}}
  • for (int l=1;l<=n;l++){
  • if (vrai){
  • switch(choix) {
  • case 0 : Cache();if (x != SUP) x+=14;
  • else if (x==SUP) x=INF;
  • Affiche(0);
  • break;
  • case 1 : Cache();if (x != INF) x-=14;
  • else if (x==INF) x=SUP;
  • Affiche(1);
  • break;
  • case 2 : Cache();y+=14;Affiche(2);break;
  • case 3 : Cache();y-=14;Affiche(3);break;
  • } delay(speed/10);
  • }
  • }
  • } else {vrai=0;Cache();delay(100); demo_music_laser();}
  • }
  • //..............................la commande principale .....................
  • void Command1(Pacman &p1,Virus p2,Virus p3,Virus p4,Virus p5)
  • {
  • int c,v;
  • int slep=0;
  • char touche;
  • int stop;
  • p1.Affiche1(1);
  • while((vrai) && (touche!=CR) && (p1.lecCPT()!=mm))
  • {
  • stop=1;
  • touche=getch();
  • if (touche==0X00)
  • touche=getch();
  • while(!kbhit()&&(vrai)&&(stop)&&(p1.lecCPT()!=mm)){
  • switch(touche) {
  • case DROIT : p1.Cache1();
  • if (getpixel(p1.lecX()+7+15,p1.lecY()+7) !=12){
  • if (p1.lecX() != SUP)
  • p1.Modifier(14,0);
  • else if (p1.lecX()==SUP)
  • p1.Modifier(-406,0);}
  • else stop=0;
  • break;
  • case GAUCH : p1.Cache1();
  • if (getpixel(p1.lecX()-15+7,p1.lecY()+7) !=12) {
  • if (p1.lecX() != INF+14)
  • p1.Modifier(-14,0);
  • else if (p1.lecX()==INF+14)
  • p1.Modifier(406,0);}
  • else stop=0;
  • break;
  • case BAS : p1.Cache1();
  • if(getpixel(p1.lecX()+7,p1.lecY()+15+7)!=12){
  • if (p1.lecY() != SUP)
  • p1.Modifier(0,14);
  • else if (p1.lecY()==SUP)
  • p1.Modifier(0,-520); }
  • else stop=0;
  • break;
  • case HAUT : p1.Cache1();
  • if (getpixel(p1.lecX()+7,p1.lecY()-15+7)!=12) {
  • if (p1.lecY() != INF)
  • p1.Modifier(0,-14);
  • else if (p1.lecY()==INF)
  • p1.Modifier(0,520); }
  • else stop=0;
  • break;
  • case ESC : exit(0);
  • }
  • if (getpixel(p1.lecX()+7,p1.lecY()+7)==2) p1.Compteur();
  • if (getpixel(p1.lecX()+7,p1.lecY()+7)==11) p1.Banane();
  • if (getpixel(p1.lecX()+7,p1.lecY()+7)==13) p1.Raisin();
  • if (getpixel(p1.lecX()+7,p1.lecY()+7)==1) p1.Pomme();
  • if (getpixel(p1.lecX()+7,p1.lecY()+7)==15) {bbb=0;p2.Affiche(3);p3.Affiche(3);p4.Affiche(3);p5.Affiche(3);slep=30;bbb=1;} //option qui stop les virus
  • if (getpixel(p1.lecX()+7,p1.lecY()+7)==9) { p1.vieADD();p1.Add();}//ajout des vies
  • p1.Affiche1(touche);delay(p1.lecS());
  • if(slep==0){
  • p2.Command2(p1,1); //la poursuite
  • p4.Command2(p1,1);
  • p3.Command3(p1,1);
  • p5.Command3(p1,1); //virus fou
  • if (p1.lecCPT() % 23 ==0) p1.Life(4); //banane
  • if (p1.lecCPT() % 13 ==0) p1.Life(3); //pomme
  • if (p1.lecCPT() % 17 ==0) p1.Life(2); //raisin
  • if (p1.lecCPT() % 55 ==0) p1.Life(1); //coeur
  • }
  • else {demo_music_ambilance();slep-=1;}
  • }
  • while (!kbhit())
  • {delay(50);p2.Command2(p1,1);p4.Command3(p1,1);p3.Command(p1,1);p5.Command2(p1,1);} //poursuit quand pac ne bouge pas
  • }
  • p1.Cache1(); //effacement de l'ancienne partie
  • p2.Cache();
  • p3.Cache();
  • p4.Cache();
  • p5.Cache();
  • }
  • //..............................le positionement des virus..................
  • void Getout(Virus &p2,Virus &p3,Virus &p4,Virus &p5)
  • {
  • DisplayImage(&sDisplay, &v19,278,260,0); //affiche get_ready
  • p2.Up(); delay(100); p4.Up(); delay(100); p3.Lf(); delay(100);
  • p5.Rg(); delay(100); p2.Up(); delay(100); p4.Up(); delay(100);
  • p3.Up(); delay(100); p5.Up(); delay(100); p2.Up(); delay(100);
  • p4.Up(); delay(100); p3.Up(); delay(100); p5.Up(); delay(100);
  • p2.Rg(); delay(100); p4.Lf(); delay(100); p3.Up(); delay(100);
  • p5.Up(); delay(100); p2.Up(); delay(100); p3.Rg(); delay(100);
  • p4.Up(); delay(100); p5.Lf(); delay(100); p2.Up(); delay(100);
  • p4.Up(); delay(100); p3.Rg(); delay(100); p5.Lf(); delay(100);
  • setcolor(0);
  • setfillstyle(1,0);
  • bar3d(278,260,390,280,0,0); //efface get ready
  • }
  • //..............................les metodes de deplacement de depart.......
  • void Virus::Up()
  • {
  • Cache();
  • y-=14;
  • Affiche(0);
  • }
  • //..........................................................................
  • void Virus::Rg()
  • {
  • Cache();
  • x+=14;
  • Affiche(0);
  • }
  • //..........................................................................
  • void Virus::Lf()
  • {
  • Cache();
  • x-=14;
  • Affiche(0);
  • }
  • //.......................sauvegarde de position initiale..................
  • void Pacman::Restore()
  • {
  • x=168+lin+21;
  • y=210+col+21+98;
  • }
  • //..........................................................................
  • void Virus::Restore2()
  • {
  • x=154+lin+21;
  • y=182+col+21;
  • }
  • //..........................................................................
  • void Virus::Restore3()
  • {
  • x=182+lin+21;
  • y=182+col+21,14;
  • }
  • //..........................................................................
  • void Virus::Restore4()
  • {
  • x=196+lin+21;
  • y=182+col+21,4;
  • }
  • //..........................................................................
  • void Virus::Restore5()
  • {
  • x=168+lin+21;
  • y=182+col+21;
  • }
  • //------------------------------- affichage du stage -----------------------
  • void Stage::affiche_stage(int n)
  • { setcolor(12);
  • SetPalette(&sDisplay, &v.ihHeader);
  • DisplayImage(&sDisplay, &v12,5,28,0);
  • DisplayImage(&sDisplay, &v13,5,90,0);
  • DisplayImage(&sDisplay, &v4,10,120,0); //v4 dessine les coeurs
  • DisplayImage(&sDisplay, &v4,30,120,0); //
  • DisplayImage(&sDisplay, &v4,50,120,0); //
  • DisplayImage(&sDisplay, &v14,5,160,0);
  • DisplayImage(&sDisplay, &v15,20,200,0);
  • DisplayImage(&sDisplay, &v16,20,230,0);
  • DisplayImage(&sDisplay, &v17,20,260,0);
  • DisplayImage(&sDisplay, &v20,540,28,0); //dessine level
  • if(n==1)DisplayImage(&sDisplay, &v21,610,28,0); //dessine level
  • if(n==2)DisplayImage(&sDisplay, &v22,610,28,0); //dessine level
  • if(n==3)DisplayImage(&sDisplay, &v23,610,28,0); //dessine level
  • int p=0;
  • gotoxy(12,3);printf("%d",p);
  • gotoxy(12,13);printf("%d",p);
  • gotoxy(12,15);printf("%d",p);
  • gotoxy(12,17);printf("%d",p);
  • int H = open("Grille.txt",O_RDWR | O_BINARY); //charge la grille from a fichier
  • if(H!=-1)
  • {
  • char c;
  • for(int j=0;j<32;j++)
  • {
  • for(int i=0;i<31;i++)
  • {
  • read(H,&c,1);
  • if(c!=13 );
  • {
  • setcolor(12);
  • setfillstyle(1,12);
  • if(c=='1') {bar3d(14*i+lin,14*j+col,14*i+lin+14,14*j+col+14,0,0);}
  • }
  • }
  • }
  • close(H);
  • }
  • }
  • //.............................affiche les boules a boufer..................
  • void Stage::point_stage()
  • {
  • for (int i=0;i<30;i++)
  • for(int j=0;j<33;j++)
  • {if (getpixel(14*i+lin,14*j+col)==0)
  • {setcolor(2);setfillstyle(SOLID_FILL,2);pieslice(14*i+lin,14*j+col,0,360,1);}}
  • setcolor(15);
  • setfillstyle(1,15);
  • pieslice(lin+28,120-17,0,360,3);
  • pieslice(lin+380-2,120-17,0,360,3);
  • pieslice(lin+28,380+17,0,360,3);
  • pieslice(lin+380-2,380+17,0,360,3);
  • }
  • //-----------------------------parti animation de classe stage--------------
  • //----------------------------animation de game ovre -----------------------
  • void Stage::Over()
  • {
  • setcolor(0);
  • setfillstyle(1,0);
  • bar3d(0,0,120,20,0,0);
  • gotoxy(1,1);printf("GAME-OVER");
  • for (int i2=0;i2<=120;i2++)
  • for (int j2=0;j2<=15;j2++)
  • {
  • setcolor(j2%9+8);
  • setfillstyle(1,j2%9+8); if (getpixel(i2,j2)!=BLACK) pieslice(i2*6+130,j2*6+200,0,360,5);
  • delay(5);
  • }
  • }
  • //----------------------------animation hight score-----------------------
  • void Stage::Animation(char *name[40],int hight)
  • {
  • gotoxy(1,1);printf("%s",name);
  • gotoxy(1,2);printf("%d",hight);
  • for (int i2=0;i2<=100;i2++)
  • for (int j2=0;j2<=100;j2++)
  • {
  • setcolor(j2%9+8);
  • setfillstyle(1,j2%9+8);
  • if (getpixel(i2,j2)!=BLACK) {putpixel(i2,j2,0);pieslice(i2*8+130,j2*8+150,0,360,2);}
  • }
  • }
  • //----------------------- animation de victoire--------------------------
  • void Stage::Winner()
  • {
  • int x1,y1,c1;
  • setcolor(0);
  • setfillstyle(1,0);
  • bar3d(0,0,120,20,0,0);
  • t_image load;
  • LoadImage(&sDisplay, "bmp/star.bmp", &load); //affichage d'etoiles
  • DisplayImage(&sDisplay, &load,0,0,0);
  • for(int l=1;l<30;l++)
  • {
  • c1=rand()%10;
  • x1=rand()%400;
  • y1=rand()%300;
  • for (int i2=0;i2<=20;i2++)
  • for (int j2=0;j2<=25;j2++)
  • {
  • setcolor(l);
  • setfillstyle(1,l);
  • if (getpixel(i2,j2)!=BLACK) pieslice(i2*c1+x1,j2*c1+y1,0,360,2);
  • }
  • }
  • setcolor(0);
  • setfillstyle(1,0);
  • bar3d(0,0,120,20,0,0);
  • gotoxy(1,1);printf("WINNER"); //affiche winner
  • for (int i2=0;i2<=60;i2++)
  • for (int j2=0;j2<=15;j2++)
  • { delay(1);
  • setcolor(15);
  • setfillstyle(1,15);
  • if (getpixel(i2,j2)!=BLACK) pieslice(i2*6+200,j2*6+210,0,360,5);
  • }
  • setcolor(0);
  • setfillstyle(1,0);
  • bar3d(195,240,480,256,0,0);
  • delay(1000);
  • DestroyImage(&load); //destructio d'image
  • }
  • //*************************programme principale***************************
  • void main()
  • {
  • InitGraphics(&sDisplay);
  • //...............................declaration................................
  • int n=1,bool=1,hight=0;
  • char nb;
  • char *name[40];
  • cleardevice();
  • Stage s(1);
  • Virus p5(154+lin+21,182+col+21,1),p2(182+lin+21,182+col+21,14),p3(196+lin+21,182+col+21,4),p4(168+lin+21,182+col+21,9);
  • Pacman p1(168+lin+21,210+col+21+98,15,2);
  • //.....................animation d'entr‚.....................................
  • s.Load();
  • s.Intro();
  • //......................chargement des images................................
  • LoadImage(&sDisplay, "bmp/blueky.bmp", &v);
  • LoadImage(&sDisplay, "bmp/pipky.bmp", &v1);
  • LoadImage(&sDisplay, "bmp/redky.bmp", &v2);
  • LoadImage(&sDisplay, "bmp/coeur1.bmp", &v4);
  • LoadImage(&sDisplay, "bmp/vide.bmp", &v5);
  • LoadImage(&sDisplay, "bmp/yelky.bmp", &v6);
  • LoadImage(&sDisplay, "bmp/hich.bmp", &v7);
  • LoadImage(&sDisplay, "bmp/hich_g.bmp", &v8);
  • LoadImage(&sDisplay, "bmp/hich_h.bmp",&v9);
  • LoadImage(&sDisplay, "bmp/hich_bas.bmp",&v10);
  • LoadImage(&sDisplay, "bmp/hich_b.bmp",&v11);
  • LoadImage(&sDisplay, "bmp/score.bmp",&v12);
  • LoadImage(&sDisplay, "bmp/life.bmp",&v13);
  • LoadImage(&sDisplay, "bmp/bonus.bmp",&v14);
  • LoadImage(&sDisplay, "bmp/pomme.bmp",&v15);
  • LoadImage(&sDisplay, "bmp/banane.bmp",&v16);
  • LoadImage(&sDisplay, "bmp/rizen.bmp",&v17);
  • LoadImage(&sDisplay, "bmp/peur.bmp",&v18);
  • LoadImage(&sDisplay, "bmp/getready.bmp",&v19);
  • LoadImage(&sDisplay, "bmp/level.bmp",&v20);
  • LoadImage(&sDisplay, "bmp/1.bmp",&v21);
  • LoadImage(&sDisplay, "bmp/2.bmp",&v22);
  • LoadImage(&sDisplay, "bmp/3.bmp",&v23);
  • LoadImage(&sDisplay, "bmp/registre.bmp",&v24);
  • //.....................affiche stage.................................................
  • s.affiche_stage(n);
  • s.point_stage();
  • p1.SPE_M(80); //vitesse de depart
  • //..........................................................................
  • while(bool)
  • {
  • while((p1.lecCPT()!=mm)&&(p1.lecVie()!=-1))
  • { Getout(p2,p3,p4,p5);
  • Command1(p1,p2,p3,p4,p5);
  • p1.Restore();
  • p5.Restore2();
  • p2.Restore3();
  • p3.Restore4();
  • p4.Restore5();
  • p1.SUB();
  • p1.vieSUB();
  • p1.Affiche1(0);
  • vrai=1;
  • }
  • if (p1.lecCPT()==mm)
  • {
  • cleardevice();
  • s.affiche_stage(n);
  • gotoxy(12,3); printf("%d",p1.lec_cpt()+p1.lec_rai()+p1.lec_ban()+p1.lec_pom());
  • delay(1000);
  • if (n<3)
  • {
  • s.Winner();
  • gotoxy(30,16);printf("VOULEZ VOUS CONTINUER O/N :");
  • scanf("%s",&nb);
  • if( nb =='n') bool=0;
  • else
  • {
  • n+=1;
  • cleardevice();p1.REMISE_0();p2.REMISE_0(); p3.REMISE_0();p4.REMISE_0();p5.REMISE_0();
  • s.affiche_stage(n);
  • s.point_stage();
  • p1.SPE_M(p1.lecS()-40);
  • }
  • }else if(n=3) bool=0;
  • }
  • else {bool=0;}
  • if(p1.lecVie()==-1){s.Over();bool=0;}
  • hight+=p1.lec_cpt()+p1.lec_rai()+p1.lec_ban()+p1.lec_pom();
  • }
  • cleardevice();
  • DisplayImage(&sDisplay, &v24,200,200,0);
  • gotoxy(35,19);scanf("%s",&name);
  • delay(100);
  • cleardevice();
  • s.Animation(name,hight);
  • printf("%d",hight);
  • DestroyImage(&v);
  • DestroyImage(&v1);
  • DestroyImage(&v2);
  • DestroyImage(&v3);
  • DestroyImage(&v4);
  • DestroyImage(&v5);
  • DestroyImage(&v6);
  • DestroyImage(&v7);
  • DestroyImage(&v8);
  • DestroyImage(&v9);
  • DestroyImage(&v10);
  • DestroyImage(&v11);
  • DestroyImage(&v12);
  • DestroyImage(&v13);
  • DestroyImage(&v14);
  • DestroyImage(&v15);
  • DestroyImage(&v16);
  • DestroyImage(&v17);
  • DestroyImage(&v18);
  • DestroyImage(&v19);
  • DestroyImage(&v20);
  • DestroyImage(&v21);
  • DestroyImage(&v22);
  • DestroyImage(&v23);
  • DestroyImage(&v24);
  • getch();
  • }
#include"stage.h"
#include<time.h>
#include <fcntl.h>
#include <io.h>

#define  ESC   0X1B
#define  CR    0XD
#define  HAUT  0X48
#define  BAS   0X50
#define  DROIT 0X4D
#define  GAUCH 0X4B

#define pi 3.1429654

#define  SUP       529
#define  INF       123
#define lin 130
#define col 20
int vrai=1;
int bbb=1;
int mm=100;
//t_screen sDisplay;
t_image v,v1,v2,v3,v4,v5,v6,v7,v8,v9,v10,v11,v12,v13,v14,v15,v16,v17,v18,v19,v20,v21,v22,v23,v24;



class Pacman;
class Virus;
class BIG_FOTHER
 {
     public :
		BIG_FOTHER(int,int,int);

		friend void Score();
		friend void demo_music_laser();
		void SPE_M(int s);
		void Modifier(int,int);
		int lecS(){return speed;}
		int lecX(){return x;}
		int lecY(){return y;}

     protected :
		int x,y,c,speed;

 };


class Virus:public BIG_FOTHER
 {
     public :
		Virus(int,int,int);
		void Affiche(int);
		void Cache();
		void Command(Pacman,int);
		void Command2(Pacman,int);
		void Command3(Pacman,int);
		friend void Getout(Virus&,Virus&,Virus&,Virus&);
		void Up();
		void Lf();
		void Rg();
		void REMISE_0();
		void Restore2();
		void Restore3();
		void Restore4();
		void Restore5();

     private :
       int bool,spool;

 };
class Pacman:public BIG_FOTHER
{ public:
	 Pacman(int,int,int,int vie);
	void Affiche1(char);
	void Cache1();
	void Life(int);
	void Add();
	void vieADD();
	void vieSUB();
	void SUB();
	void Restore();
	void Compteur();
	void Pomme();
	void Banane();
	void Raisin();
	int lec_cpt(){return cpt;}
	int lec_pom(){return pom;}
	int lec_ban(){return ban;}
	int lec_rai(){return rai;}

	void Play();
	void REMISE_0();
	int lecCPT(){return cpt;}
	void Modifier_cpt(int);
	int lecVie(){return vie;}
	friend void Command1(Pacman&,Virus,Virus,Virus,Virus);


  private:
	 int vie,ban,rai,pom,cpt;
};


//----------------------------------- constructeur big_fother -------------
BIG_FOTHER::BIG_FOTHER(int x1,int y1,int c1)
{
x=x1;
y=y1;
c=c1;
speed=80;
}
//-------------------------------------------------------------------------
void BIG_FOTHER::SPE_M(int s)
{
speed=s;
}
//----------------------------------- constructeur virus--------------------
Virus::Virus(int x1,int y1,int c1):BIG_FOTHER(x1,y1,c1)
{
spool=0;
bool=0;
}
//----------------------------------- constructeur pacman--------------------
Pacman::Pacman(int a,int b,int c1,int v1):BIG_FOTHER(a,b,c1)
{
ban=0;
rai=0;
pom=0;
vie=v1;
cpt=0;
}
//-------------------------------------------------------------------------
void Pacman::REMISE_0()
{
ban=0;
rai=0;
pom=0;
vie=2;
cpt=0;
vrai=1;
}
//-----------------------------------------------------------------------
void Virus::REMISE_0()
{
spool=0;
bool=0;

}

//----------------------------------- partie sonor--------------------------
void demo_music_laser()
{
    for(int count=0;count<10;count++)
	{sound(count*100);delay(10);}
     nosound();

}
//..........................................................................
void demo_music_ambilance()
{
     for(int count=0;count<2;count++)
	{sound(4000);delay(5);sound(7000);delay(5);}
     nosound();

}


//------------------------------------ les methodes de big_fother------------

void BIG_FOTHER::Modifier(int x1,int y1)
{
x=(x+x1) ;
y=(y+y1) ;

}
//----------------------------------- les methodes de pacman----------------
void Pacman::Compteur()
{
cpt+=1;
gotoxy(12,3);printf("%d",cpt);
	 sound(7000);
	 delay(50);
	 nosound();

}
//.........................................................................
void Pacman::Pomme()
{
pom+=20;
gotoxy(12,13);printf("%d",pom);
	 sound(5000);
	 delay(50);
	 nosound();

}
//........................................................................
void Pacman::Banane()
{
ban+=50;
gotoxy(12,15);printf("%d",ban);
	 sound(5000);
	 delay(50);
	 nosound();

}
//........................................................................
void Pacman::Raisin()
{
rai+=100;
gotoxy(12,17);printf("%d",rai);
	 sound(7000);
	 delay(50);
	 nosound();

}
//.......................................................................
void Pacman::vieADD()
{
vie+=1;
}
//........................................................................
void Pacman::vieSUB()
{
vie=vie-1;
}
//........................................................................
void Pacman::Add()
{
DisplayImage(&sDisplay, &v4,10+20*vie,120,0);
	 sound(7000);
	 delay(50);
	 nosound();

}
//.........................................................................
void Pacman::SUB()
{
DisplayImage(&sDisplay, &v5,10+20*vie,120,0);
}

//.........................................................................
void Pacman::Affiche1(char n)
{
SetPalette(&sDisplay, &v.ihHeader);
setcolor(15);
setfillstyle(1,15);

   switch(n)
   {
   case DROIT  :pieslice(lecX()+7,lecY()+7,0,360,5);delay(20);DisplayImage(&sDisplay, &v7,lecX(),lecY(),0);break;
   case HAUT   :pieslice(lecX()+7,lecY()+7,0,360,5);delay(20);DisplayImage(&sDisplay, &v9,lecX(),lecY(),0);break;
   case BAS    :pieslice(lecX()+7,lecY()+7,0,360,5);delay(20);DisplayImage(&sDisplay, &v10,lecX(),lecY(),0);break;
   case GAUCH  :pieslice(lecX()+7,lecY()+7,0,360,5);delay(20);DisplayImage(&sDisplay, &v8,lecX(),lecY(),0);break;
   }

}
//..........................................................................
void Pacman::Life(int n)
{
int ii,jj;
setfillstyle(1,4);
randomize();
ii=rand() % 30;
jj=rand() % 30;
if (getpixel(14*ii+lin+21+7,14*jj+col+21+7)!=12)
   if (( 14*ii+lin+21 < 500)&&(14*jj+col+21 < 400))
  { if (n==1){DisplayImage(&sDisplay, &v4,14*ii+lin+21,14*jj+col+21,0); }
    if (n==2){DisplayImage(&sDisplay, &v15,14*ii+lin+21,14*jj+col+21,0); }
    if (n==3){DisplayImage(&sDisplay, &v16,14*ii+lin+21,14*jj+col+21,0); }
    if (n==4){DisplayImage(&sDisplay, &v17,14*ii+lin+21,14*jj+col+21,0); }
  }
}

//..........................................................................
void Pacman::Cache1()
{
DisplayImage(&sDisplay, &v5,lecX(),lecY(),0);
}

//------------------------------- les methodes de virus---------------------

void Virus::Affiche(int n)
{
SetPalette(&sDisplay, &v.ihHeader);
bool=0;
spool=0;
if(getpixel(x+7,y+7)==2) bool=1;
if(getpixel(x+7,y+7)==15) spool=1;
if (bbb)
{
if (c==4) {DisplayImage(&sDisplay, &v,x,y,0); }
if (c==9) {DisplayImage(&sDisplay, &v1,x,y,0); }
if (c==14) {DisplayImage(&sDisplay, &v2,x,y,0); }
if (c==1) {DisplayImage(&sDisplay, &v6,x,y,0); }
if (c==13) {DisplayImage(&sDisplay, &v7,x,y,0); }
setcolor(0);
setfillstyle(1,0);
switch(n)
	{
	case 0:  pieslice(x+7,y+4,0,360,1);
		 pieslice(x+12,y+4,0,360,1);
		 break;
	case 1:  pieslice(x+4,y+4,0,360,1);
		 pieslice(x+8,y+4,0,360,1);

		 break;
	case 2:  pieslice(x+5,y+6,0,360,1);
		 pieslice(x+10,y+6,0,360,1);

		 break;
	case 3:  pieslice(x+5,y+2,0,360,1);
		 pieslice(x+10,y+2,0,360,1);

		 break;
	}
}
else DisplayImage(&sDisplay, &v18,x,y,0);     //image de la peur v18

}
//.........................................................................
void Virus::Cache()
{
DisplayImage(&sDisplay, &v5,x,y,0);
if (bool)  { setcolor(2);setfillstyle(SOLID_FILL,2);pieslice(x+7,y+7,0,360,1);}
//if (spool) { setcolor(15);setfillstyle(SOLID_FILL,15);pieslice(x+7,y+7,0,360,3);}
}
//.........................................................................
void Virus::Command(Pacman p,int n)
{
int choix;
  if (( x != p.lecX() ) || ( y != p.lecY() ))
      {if (x != p.lecX())
	 {if (x < p.lecX()) {if ((getpixel(x+7+15,y+7)!=12)) choix=0;else if (getpixel(x+7,y-15+7)!=12) choix=3;}
	  else {if ((getpixel(x-15+7,y+7)!=12)) choix=1;else if(getpixel(x+7,y+7-15)!=12) choix=2;}}
      else
	 {if (y < p.lecY()) {if(getpixel(x+7,y+15+7)!=12) choix=2;else if (getpixel(x+15+7,y+7)!=12) choix=0;}
	  else {if (getpixel(x+7,y-15+7)!=12) choix=3;else if (getpixel(x-15+7,y+7)!=12) choix=1;}}

for (int l=1;l<=n;l++)
	     {
if (vrai){
  switch(choix) {
		   case 0:         Cache();x+=14;Affiche(0);
				   break;
		   case 1 	:  Cache();x-=14;Affiche(1);
				   break;
		   case 2      :   Cache();y+=14;Affiche(2);
				   break;
		   case 3 	:  Cache();y-=14;Affiche(3);
				   break;
		 }

		 delay(speed/10);
	     }
	}
   }
    else {vrai=0;Cache();delay(100);demo_music_laser();}
}

//........................................................................
void Virus::Command3(Pacman p,int n)
{
int choix;
randomize();
int non=1;
while(non)
{
choix=rand()%4;
switch(choix)
  {
	case 0:if (getpixel(x+7+15,y+7)!=12) non=0;break;
	case 1:if(getpixel(x+7-15,y+7)!=12)  non=0;break;
	case 2:if (getpixel(x+7,y+7+15)!=12) non=0;break;
     //	case 3:if (getpixel(x+7,y+7-15)!=12) non=0;break;
  }
}

 if ( (x!=p.lecX())||(y != p.lecY()) )
	    {
	       for (int l=1;l<=n;l++){
		   if (vrai){
			switch(choix) {
				case 0  : Cache();if (x != SUP) x+=14;
					  else if (x==SUP) x=INF;
					  Affiche(0);
					  break;
				case 1 	: Cache();if (x != INF) x-=14;
					  else if (x==INF) x=SUP;
					  Affiche(1);
					  break;
				case 2  : Cache();y+=14;Affiche(2);
					  break;
				case 3 	: Cache();y-=14;Affiche(3);
					  break;
				       } delay(speed/10);
				     }
	    }

       }
	 else {vrai=0;Cache();delay(100); demo_music_laser();}
}
//..........................................................................
void Virus::Command2(Pacman p,int n)
{
int choix;
if ( (x!=p.lecX())||(y != p.lecY()) )
       {if (y != p.lecY())
	  {if (y < p.lecY()) {if ((getpixel(x+7,y+7+15)!=12)) choix=2;else if ((getpixel(x+7-15,y+7)!=12)) choix=1;}
	   else {if ((getpixel(x+7,y+7-15)!=12)) choix=3;else if ((getpixel(x+7+15,y+7)!=12)) choix=0;}}
       else
	  {if (x < p.lecX()) {if((getpixel(x+15+7,y+7)!=12)) choix=0;else if ((getpixel(x+7,y-15+7)!=12)) choix=3;}
	   else {if ((getpixel(x-15+7,y+7)!=12)) choix=1;else if ((getpixel(x+7,y+7+15)!=12)) choix=2;}}

for (int l=1;l<=n;l++){
	 if (vrai){
		switch(choix) {
			case 0 : Cache();if (x != SUP) x+=14;
				 else if (x==SUP) x=INF;
				 Affiche(0);
				 break;
			case 1 : Cache();if (x != INF) x-=14;
				 else if (x==INF) x=SUP;
				 Affiche(1);
				 break;
			case 2 : Cache();y+=14;Affiche(2);break;
			case 3 : Cache();y-=14;Affiche(3);break;
			      } delay(speed/10);
		       }
	      }
      }  else {vrai=0;Cache();delay(100); demo_music_laser();}
}

//..............................la commande principale .....................
void Command1(Pacman &p1,Virus p2,Virus p3,Virus p4,Virus p5)
{
int c,v;
int slep=0;
char touche;
int stop;
p1.Affiche1(1);
while((vrai) && (touche!=CR) && (p1.lecCPT()!=mm))
 {
  stop=1;
  touche=getch();
  if (touche==0X00)
  touche=getch();
	    while(!kbhit()&&(vrai)&&(stop)&&(p1.lecCPT()!=mm)){
		   switch(touche) {
				   case DROIT :   p1.Cache1();
						  if (getpixel(p1.lecX()+7+15,p1.lecY()+7) !=12){
						  if (p1.lecX() != SUP)
						  p1.Modifier(14,0);
						  else if (p1.lecX()==SUP)
						  p1.Modifier(-406,0);}
						  else stop=0;
						  break;

				   case GAUCH :  p1.Cache1();
						 if (getpixel(p1.lecX()-15+7,p1.lecY()+7) !=12) {
						 if (p1.lecX() != INF+14)
						 p1.Modifier(-14,0);
						 else if (p1.lecX()==INF+14)
						 p1.Modifier(406,0);}
						 else stop=0;
						 break;

				    case BAS  :  p1.Cache1();
						 if(getpixel(p1.lecX()+7,p1.lecY()+15+7)!=12){
						 if (p1.lecY() != SUP)
						 p1.Modifier(0,14);
						 else if (p1.lecY()==SUP)
						 p1.Modifier(0,-520);  }
						 else stop=0;
						 break;

				    case HAUT :  p1.Cache1();
						 if (getpixel(p1.lecX()+7,p1.lecY()-15+7)!=12)  {
						 if (p1.lecY() != INF)
						 p1.Modifier(0,-14);
						 else if (p1.lecY()==INF)
						 p1.Modifier(0,520);  }
						 else stop=0;
						 break;

				    case ESC  :  exit(0);

		}
		if (getpixel(p1.lecX()+7,p1.lecY()+7)==2)  p1.Compteur();
		if (getpixel(p1.lecX()+7,p1.lecY()+7)==11) p1.Banane();
		if (getpixel(p1.lecX()+7,p1.lecY()+7)==13) p1.Raisin();
		if (getpixel(p1.lecX()+7,p1.lecY()+7)==1)  p1.Pomme();
		if (getpixel(p1.lecX()+7,p1.lecY()+7)==15) {bbb=0;p2.Affiche(3);p3.Affiche(3);p4.Affiche(3);p5.Affiche(3);slep=30;bbb=1;} //option qui stop les virus
		if (getpixel(p1.lecX()+7,p1.lecY()+7)==9) { p1.vieADD();p1.Add();}//ajout des vies
		p1.Affiche1(touche);delay(p1.lecS());
		if(slep==0){
			   p2.Command2(p1,1);     //la poursuite
			   p4.Command2(p1,1);
			   p3.Command3(p1,1);
			   p5.Command3(p1,1);     //virus fou

		 if (p1.lecCPT() % 23 ==0) p1.Life(4);  //banane
		 if (p1.lecCPT() % 13 ==0) p1.Life(3);  //pomme
		 if (p1.lecCPT() % 17 ==0) p1.Life(2);  //raisin
		 if (p1.lecCPT() % 55 ==0) p1.Life(1);  //coeur

			   }
		 else {demo_music_ambilance();slep-=1;}
	 }

		while (!kbhit())
		     {delay(50);p2.Command2(p1,1);p4.Command3(p1,1);p3.Command(p1,1);p5.Command2(p1,1);} //poursuit quand pac ne bouge pas

	}
	p1.Cache1();  //effacement de l'ancienne partie
	p2.Cache();
	p3.Cache();
	p4.Cache();
	p5.Cache();
}
//..............................le positionement des virus..................
void Getout(Virus &p2,Virus &p3,Virus &p4,Virus &p5)
{
  DisplayImage(&sDisplay, &v19,278,260,0);  //affiche get_ready
   p2.Up(); delay(100); p4.Up();  delay(100); p3.Lf(); delay(100);
   p5.Rg(); delay(100); p2.Up();  delay(100); p4.Up(); delay(100);
   p3.Up(); delay(100); p5.Up();  delay(100); p2.Up(); delay(100);
   p4.Up(); delay(100); p3.Up();  delay(100); p5.Up(); delay(100);
   p2.Rg(); delay(100); p4.Lf();  delay(100); p3.Up(); delay(100);
   p5.Up(); delay(100); p2.Up();  delay(100); p3.Rg(); delay(100);
   p4.Up(); delay(100); p5.Lf();  delay(100); p2.Up(); delay(100);
   p4.Up(); delay(100); p3.Rg();  delay(100); p5.Lf(); delay(100);
   setcolor(0);
   setfillstyle(1,0);
   bar3d(278,260,390,280,0,0);  //efface get ready

}
//..............................les metodes  de deplacement de depart.......
void Virus::Up()
{
Cache();
y-=14;
Affiche(0);
}
//..........................................................................
void Virus::Rg()
{
Cache();
x+=14;
Affiche(0);
}
//..........................................................................
void Virus::Lf()
{
Cache();
x-=14;
Affiche(0);
}
//.......................sauvegarde  de position initiale..................
void Pacman::Restore()
{
x=168+lin+21;
y=210+col+21+98;
}
//..........................................................................
void Virus::Restore2()
{
x=154+lin+21;
y=182+col+21;
}
//..........................................................................
void Virus::Restore3()
{
x=182+lin+21;
y=182+col+21,14;
}
//..........................................................................
void Virus::Restore4()
{
x=196+lin+21;
y=182+col+21,4;
}
//..........................................................................
void Virus::Restore5()
{
x=168+lin+21;
y=182+col+21;
}

//------------------------------- affichage du stage -----------------------
void Stage::affiche_stage(int n)
{ setcolor(12);
SetPalette(&sDisplay, &v.ihHeader);
DisplayImage(&sDisplay, &v12,5,28,0);
DisplayImage(&sDisplay, &v13,5,90,0);
DisplayImage(&sDisplay, &v4,10,120,0);   //v4 dessine les coeurs
DisplayImage(&sDisplay, &v4,30,120,0);   //
DisplayImage(&sDisplay, &v4,50,120,0);   //
DisplayImage(&sDisplay, &v14,5,160,0);
DisplayImage(&sDisplay, &v15,20,200,0);
DisplayImage(&sDisplay, &v16,20,230,0);
DisplayImage(&sDisplay, &v17,20,260,0);
DisplayImage(&sDisplay, &v20,540,28,0);     //dessine level

if(n==1)DisplayImage(&sDisplay, &v21,610,28,0);     //dessine level
if(n==2)DisplayImage(&sDisplay, &v22,610,28,0);     //dessine level
if(n==3)DisplayImage(&sDisplay, &v23,610,28,0);     //dessine level
int p=0;
gotoxy(12,3);printf("%d",p);
gotoxy(12,13);printf("%d",p);
gotoxy(12,15);printf("%d",p);
gotoxy(12,17);printf("%d",p);
 int H = open("Grille.txt",O_RDWR | O_BINARY);  //charge la grille from a fichier
 if(H!=-1)
  {
   char c;
   for(int j=0;j<32;j++)
    {
     for(int i=0;i<31;i++)
      {
       read(H,&c,1);
       if(c!=13 );
	{
	setcolor(12);
	setfillstyle(1,12);
	 if(c=='1') {bar3d(14*i+lin,14*j+col,14*i+lin+14,14*j+col+14,0,0);}

      }
     }
  }

   close(H);
 }

}
//.............................affiche les boules a boufer..................
void Stage::point_stage()
{

for (int i=0;i<30;i++)
  for(int j=0;j<33;j++)
     {if (getpixel(14*i+lin,14*j+col)==0)
     {setcolor(2);setfillstyle(SOLID_FILL,2);pieslice(14*i+lin,14*j+col,0,360,1);}}
	setcolor(15);
	setfillstyle(1,15);
	pieslice(lin+28,120-17,0,360,3);
	pieslice(lin+380-2,120-17,0,360,3);
	pieslice(lin+28,380+17,0,360,3);
	pieslice(lin+380-2,380+17,0,360,3);
}
//-----------------------------parti animation de classe stage--------------
//----------------------------animation de game ovre -----------------------
void Stage::Over()
{
setcolor(0);
setfillstyle(1,0);
bar3d(0,0,120,20,0,0);
gotoxy(1,1);printf("GAME-OVER");
for (int i2=0;i2<=120;i2++)
  for (int j2=0;j2<=15;j2++)
  {
    setcolor(j2%9+8);
    setfillstyle(1,j2%9+8);                                        if (getpixel(i2,j2)!=BLACK) pieslice(i2*6+130,j2*6+200,0,360,5);
    delay(5);
  }
}
//----------------------------animation hight score-----------------------
void Stage::Animation(char *name[40],int hight)
{
gotoxy(1,1);printf("%s",name);
gotoxy(1,2);printf("%d",hight);
for (int i2=0;i2<=100;i2++)
  for (int j2=0;j2<=100;j2++)
  {
    setcolor(j2%9+8);
    setfillstyle(1,j2%9+8);
    if (getpixel(i2,j2)!=BLACK) {putpixel(i2,j2,0);pieslice(i2*8+130,j2*8+150,0,360,2);}
  }

}
//----------------------- animation de victoire--------------------------
void Stage::Winner()
{
int x1,y1,c1;
setcolor(0);
setfillstyle(1,0);
bar3d(0,0,120,20,0,0);
      t_image load;
   LoadImage(&sDisplay, "bmp/star.bmp", &load);              //affichage  d'etoiles

   DisplayImage(&sDisplay, &load,0,0,0);
for(int l=1;l<30;l++)
{
c1=rand()%10;
x1=rand()%400;
y1=rand()%300;
for (int i2=0;i2<=20;i2++)
  for (int j2=0;j2<=25;j2++)
  {
    setcolor(l);
    setfillstyle(1,l);
    if (getpixel(i2,j2)!=BLACK) pieslice(i2*c1+x1,j2*c1+y1,0,360,2);

  }
}
setcolor(0);
setfillstyle(1,0);
bar3d(0,0,120,20,0,0);
gotoxy(1,1);printf("WINNER");                //affiche winner
for (int i2=0;i2<=60;i2++)
  for (int j2=0;j2<=15;j2++)
  { delay(1);
    setcolor(15);
    setfillstyle(1,15);
    if (getpixel(i2,j2)!=BLACK) pieslice(i2*6+200,j2*6+210,0,360,5);

  }
setcolor(0);
setfillstyle(1,0);
bar3d(195,240,480,256,0,0);
delay(1000);
DestroyImage(&load);            //destructio d'image
}

//*************************programme principale***************************
void main()
{

InitGraphics(&sDisplay);
//...............................declaration................................
int n=1,bool=1,hight=0;
char nb;
char *name[40];
cleardevice();
Stage s(1);
Virus p5(154+lin+21,182+col+21,1),p2(182+lin+21,182+col+21,14),p3(196+lin+21,182+col+21,4),p4(168+lin+21,182+col+21,9);
Pacman p1(168+lin+21,210+col+21+98,15,2);

//.....................animation d'entr‚.....................................
s.Load();
s.Intro();

//......................chargement des images................................
    LoadImage(&sDisplay, "bmp/blueky.bmp", &v);
      LoadImage(&sDisplay, "bmp/pipky.bmp", &v1);
      LoadImage(&sDisplay, "bmp/redky.bmp", &v2);
      LoadImage(&sDisplay, "bmp/coeur1.bmp", &v4);
      LoadImage(&sDisplay, "bmp/vide.bmp", &v5);
      LoadImage(&sDisplay, "bmp/yelky.bmp", &v6);
      LoadImage(&sDisplay, "bmp/hich.bmp", &v7);
      LoadImage(&sDisplay, "bmp/hich_g.bmp", &v8);
      LoadImage(&sDisplay, "bmp/hich_h.bmp",&v9);
      LoadImage(&sDisplay, "bmp/hich_bas.bmp",&v10);
      LoadImage(&sDisplay, "bmp/hich_b.bmp",&v11);
      LoadImage(&sDisplay, "bmp/score.bmp",&v12);
      LoadImage(&sDisplay, "bmp/life.bmp",&v13);
      LoadImage(&sDisplay, "bmp/bonus.bmp",&v14);
      LoadImage(&sDisplay, "bmp/pomme.bmp",&v15);
      LoadImage(&sDisplay, "bmp/banane.bmp",&v16);
      LoadImage(&sDisplay, "bmp/rizen.bmp",&v17);
      LoadImage(&sDisplay, "bmp/peur.bmp",&v18);
      LoadImage(&sDisplay, "bmp/getready.bmp",&v19);
      LoadImage(&sDisplay, "bmp/level.bmp",&v20);
      LoadImage(&sDisplay, "bmp/1.bmp",&v21);
      LoadImage(&sDisplay, "bmp/2.bmp",&v22);
      LoadImage(&sDisplay, "bmp/3.bmp",&v23);
      LoadImage(&sDisplay, "bmp/registre.bmp",&v24);
//.....................affiche stage.................................................
s.affiche_stage(n);
s.point_stage();
p1.SPE_M(80);    //vitesse de depart
//..........................................................................
while(bool)
{
  while((p1.lecCPT()!=mm)&&(p1.lecVie()!=-1))
    { Getout(p2,p3,p4,p5);
      Command1(p1,p2,p3,p4,p5);
      p1.Restore();
      p5.Restore2();
      p2.Restore3();
      p3.Restore4();
      p4.Restore5();
      p1.SUB();
      p1.vieSUB();
      p1.Affiche1(0);
      vrai=1;
    }
if (p1.lecCPT()==mm)
		    {
		     cleardevice();
		     s.affiche_stage(n);
		     gotoxy(12,3); printf("%d",p1.lec_cpt()+p1.lec_rai()+p1.lec_ban()+p1.lec_pom());

		     delay(1000);

		     if (n<3)
		     {
			  s.Winner();
			  gotoxy(30,16);printf("VOULEZ VOUS CONTINUER O/N :");
			  scanf("%s",&nb);
			  if( nb =='n') bool=0;
			  else
			       {
			       n+=1;
			       cleardevice();p1.REMISE_0();p2.REMISE_0(); p3.REMISE_0();p4.REMISE_0();p5.REMISE_0();
			       s.affiche_stage(n);
			       s.point_stage();
			       p1.SPE_M(p1.lecS()-40);
			       }

		     }else if(n=3) bool=0;
		   }
else {bool=0;}
if(p1.lecVie()==-1){s.Over();bool=0;}
hight+=p1.lec_cpt()+p1.lec_rai()+p1.lec_ban()+p1.lec_pom();
}

	   cleardevice();
	   DisplayImage(&sDisplay, &v24,200,200,0);
	   gotoxy(35,19);scanf("%s",&name);
	   delay(100);
	   cleardevice();
	   s.Animation(name,hight);
	   printf("%d",hight);

DestroyImage(&v);
DestroyImage(&v1);
DestroyImage(&v2);
DestroyImage(&v3);
DestroyImage(&v4);
DestroyImage(&v5);
DestroyImage(&v6);
DestroyImage(&v7);
DestroyImage(&v8);
DestroyImage(&v9);
DestroyImage(&v10);
DestroyImage(&v11);
DestroyImage(&v12);
DestroyImage(&v13);
DestroyImage(&v14);
DestroyImage(&v15);
DestroyImage(&v16);
DestroyImage(&v17);
DestroyImage(&v18);
DestroyImage(&v19);
DestroyImage(&v20);
DestroyImage(&v21);
DestroyImage(&v22);
DestroyImage(&v23);
DestroyImage(&v24);

getch();

}

 Conclusion

il manque le zip la semaine prochaine je les completerai


peut etre y a un probleme avec l'instruction <delay> dans certain pc vous remarqué que le jeu ne fonctionne pas correctement .
je vous assurre que le jeu est bien fait et se probleme et hors de mes connaissance.

 Fichier Zip

Les Membres Club peuvent télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !

Télécharger le zip


 Historique

15 juin 2005 20:14:50 :
voila j'ai ajouter les fichier restant

 Sources du même auteur

Source avec Zip EDITEUR DE TEXTE
Source avec Zip JEUX D'ECHEC
Source avec Zip PUZZLE
PACMAN

 Sources de la même categorie

Source avec Zip Source avec une capture JEUX SERPENT par antho974
Source avec Zip Source avec une capture PENDU EN SDL par Damsou91
Source avec Zip STATE MACHINE MODIFICATION MATH BUCKHAM par billybones79
Source avec Zip AUTRE GRILLE DE SUDOKU par Eneur
Source avec Zip Source avec une capture SOKOBAN EN C POUR DÉBUTANT (VERSION AMÉLIORÉE BASÉE SUR LE T... par eustatika

 Sources en rapport avec celle ci

Source avec Zip PUCKMAN PROJET C GEII par aurelbo
Source avec Zip Source avec une capture PACMAN SDL FMOD par Krazy_V
Source avec Zip PACMAN ENTIEREMENT EN C par adil972223
Source avec Zip Source avec une capture R-PACMAN EN C++ AVEC LA SDL ET FMOD par Rouliann
Source avec Zip PACMAN EN C par tastalian

Commentaires et avis

Commentaire de Joky le 14/06/2005 21:11:20

Ah mé mon dieu !!!
Déjà quand ya un zip, y'en à qui galère à compiler
Alors si en plus y'a tout le code coller en vrac lol
Ton code va vite partir aux oubliettes...
J'te conseille de mettre à jours, et en même temps de faire une recherche sur PACMAN sur le site lol
Tu verras c'est esstraordinaire ;)

Commentaire de vecchio56 le 15/06/2005 00:00:42 administrateur CS

C'est du turbo C++ donc même avec un zip ca va pas trop le faire

Commentaire de BruNews le 15/06/2005 00:05:02 administrateur CS

C'est déjà aux oubliettes et depuis plus de 10 ans.

Commentaire de NeT0n le 15/06/2005 07:37:22

Quel importance ??!!, on sais que le programme marche alors autant essayer de le comprendre pour pouvoir réutiliser certaines partie...

Commentaire de MuPuF le 15/06/2005 13:17:08

Avant de voir comment marche un prog on regarde ce qu'il fait !
Pas l'inverse (c'est assez con de se casser la tete a lire les commentaires et encore, si ils existent).

Commentaire de Todd51 le 15/06/2005 19:42:16

y marche pas ton code ou alors il en manque un bon

Commentaire de NeT0n le 16/06/2005 00:29:53

ba en meme temps on sais que c'est un pacman donc on à une idée assez précise du fonctionement
Mais il est vrai que le voir permet de mieux comprendre ensuite

Commentaire de Ombitious_Developper le 16/06/2005 12:16:22

Salut :
Votre code source contient plusieurs fonctions intéressantes .
Pouvez vous m'envoyer le code source pour :
- Afficher une image *.BMP
- Détruire une image *.BMP  

Commentaire de Sizlaa le 16/06/2005 19:23:57

Hello,
Une chose me choque déjà a la vue de ton programme, c'est la fin, Une 20aine de ligne pour la même choses, je pense que tu aurais pu utiliser une boucle (a méditer j'en suis pas sur)
Je n'ai pas encore testé le prog, il contient (comme ce qui a été dit précédemment) quelques fonctions intéressantes

++ et bonne continuation

  

Commentaire de AmK le 17/06/2005 14:00:36

effectivement, vaut mieux stocker tt dans un tableau et puis boucler le DestroyImage ....
tu aurais pu aussi découper ton code en plusieurs .h et .cpp

Commentaire de wxccxw le 11/06/2006 17:33:21

il suffirai de mettre v dans un tableau et de faire :

for(int i = 0; i < 20; i++)
{
destroy(&v[i]);
}

 Ajouter un commentaire


Discussions en rapport avec ce code source dans le forum

PACMAN [ par firesnake ] Bonjour tout le monde! Je viens de terminer mon premier jeu DOS en Borland C++ : PACMAN 1.0. C'est plutot une version de test qu'un jeu à part entière le dur chemin du debutant...? [ par zevince ] Salut,je decouvre ce site.. et ca a l'air bien cool et y'a l'air d'y avoir du passage.. ca tombe bien !moi : je connais bien html, xml, xslt et j'ai d Besoin d'images pour un jeu de rôle [ par LightningFlik ] Voilà, je fais un jeu de rôle et je n'ai pas d'images. Je pourrais évidemment les prendre dans d'autres jeux (c'et ce que j'ai fait mais ce n'est que recherche [ par arnaudcoutant ] je recherche des personnes, codeurs, graphistes, infographistes ,etc... connaissant le c++ ou opengl pour réaliser un jeu vidéos pc, si cela vous inte urgent recherche très vite [ par arnaudcoutant ] je recherche des personnes, codeurs, graphistes, infographistes ,etc... connaissant le c++ ou opengl pour réaliser un jeu vidéos pc, si cela vous inte **recherche très vite personne interréssé ********* [ par arnaudcoutant ] je recherche des personnes, codeurs, graphistes, infographistes ,etc... connaissant le c++ ou opengl pour réaliser un jeu vidéos pc, si cela vous inte pour ,prog c++ et 2D vite [ par arnaudcoutant ] je recherche des personnes, codeurs, graphistes, infographistes ,etc... connaissant le c++ ou opengl pour réaliser un jeu vidéos pc, si cela vous inte Jeu DirectX [ par Mickylord ] Bonjour , je vien de commencer a faire mon premier jeu en DirectX , mais j'ai un petit problème : J'aimerai que quand j'appui sur la touche droite ( p recherche codeur et programeur [ par loicus ] Bonjours, tout le monde, je suis a la recherche de programeur et de codeur c++, pour la programation d'un jeu de strategie temp réel,Ce jeu sera doté Comment mettre en commun deux surfaces ? [ par JMGR ] Bonjour,Je dévellope un jeu de stratégie en 2D, je crée des tiles de 10*10 pixels et mon jeu est en 800*600.Donc si je fait comme ça, ça rame énorméme


Nos sponsors


Sondage...

CalendriCode

Février 2012
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
272829    

Consulter la suite du CalendriCode

Photothèque

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 1,451 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales