begin process at 2012 05 27 17:39:17
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Graphique

 > PACMAN

PACMAN


 Information sur la source

Note :
5,67 / 10 - par 3 personnes
5,67 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :Graphique Niveau :Débutant Date de création :28/04/2005 Vu :4 224

Auteur : xmenneo2003

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

 Description

pacman est un jeux developper en language turbo c++
bon exemple pour vous initialiser a la programmation orineté objet

Source

  • #include<stdlib.h>
  • #include<graphics.h>
  • #include<math.h>
  • #include<stdio.H>
  • #include<string.h>
  • #include<conio.h>
  • #include<dos.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 420
  • #define INF 80
  • #define lin 70
  • #define col 70
  • int vrai=1;
  • int cpt=0;
  • int mat[18][18];
  • int u;
  • void affiche_stage(int mat[18][18]);
  • void point_stage(int mat[18][18]);
  • void Remplir_mat(int mat[18][18]);
  • class Virus
  • {
  • public :
  • Virus(int,int,int,int);
  • void Affiche(int);
  • friend void Score();
  • friend void demo_music_laser();
  • void Cache();
  • void Cache1();
  • void Command(Virus,int);
  • void Command2(Virus,int);
  • friend void Command1(Virus,Virus,Virus,Virus);
  • void Affiche1(char);
  • void Life();
  • void Add();
  • void vieADD();
  • void vieSUB();
  • void Compteur();
  • void Modifier(int,int);
  • int lecX(){return x;}
  • int lecY(){return y;}
  • int lecVie(){return vie;}
  • private :
  • int x,y;int c,vie;
  • };
  • //-----------------------------------
  • Virus::Virus(int x1,int y1,int c1,int v)
  • {
  • x=x1;
  • y=y1;
  • c=c1;
  • vie=v;
  • }
  • //-----------------------------------
  • 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();
  • }
  • //------------------------------------
  • void Virus::Compteur()
  • {
  • cpt+=1;
  • gotoxy(1,1);printf("SCORE : %d",cpt);
  • sound(7000);
  • delay(50);
  • nosound();
  • }
  • //-----------------------------------
  • //-----------------------------------
  • void Virus::Modifier(int x1,int y1)
  • {
  • x=(x+x1) ;
  • y=(y+y1) ;
  • }
  • void Virus::vieADD()
  • {
  • vie+=1;
  • }
  • void Virus::vieSUB()
  • {
  • vie-=1;
  • }
  • //-----------------------------------
  • void Virus::Affiche(int n)
  • {
  • setcolor(c);
  • //arc (x,y-1,0,180,8); //tete
  • arc (x,y+4,-160,-20,4); //bouche
  • arc (x,y+3,35,145,10);
  • setfillstyle(SOLID_FILL,15);
  • setcolor(15);
  • pieslice(x-4,y,0,360,3); //lunette
  • pieslice(x+4,y,0,360,3);
  • setfillstyle(SOLID_FILL,0); //
  • setcolor(0);
  • switch(n){
  • case 0: pieslice(x-3,y,0,360,2);
  • pieslice(x+7,y,0,360,2);
  • break;
  • case 1: pieslice(x-7,y,0,360,2);
  • pieslice(x+3,y,0,360,2);
  • break;
  • case 2: pieslice(x-5,y+3,0,360,2);
  • pieslice(x+5,y+3,0,360,2);
  • break;
  • case 3: pieslice(x-5,y-3,0,360,2);
  • pieslice(x+5,y-3,0,360,2);
  • break;
  • }
  • }
  • //------------------------------------------
  • void Virus::Affiche1(char n)
  • {
  • setcolor(c);
  • setfillstyle(1,15);
  • pieslice(lecX(),lecY(),0, 360, 8);
  • floodfill(lecX(),lecY(),15);
  • delay(10);
  • setcolor(0);setfillstyle(1,0);
  • switch(n){
  • case DROIT :pieslice(lecX(),lecY(),0,30,8);break;
  • case HAUT : pieslice(lecX(),lecY(),70,110,8);break;
  • case BAS : pieslice(lecX(),lecY(),-80,-120,8);break;
  • case GAUCH : pieslice(lecX(),lecY(),160,210,8);break;
  • }
  • }
  • //""""""""""""""""""""""""""""""""""
  • void Virus::Life()
  • {
  • int ii,jj;
  • //fillellipse(210,240,8,8);
  • setcolor(4);
  • setfillstyle(1,4);
  • randomize();
  • ii=rand() % 18;
  • jj=rand() % 18;
  • if (getpixel(40*ii+col+10,40*jj+lin+10)!=YELLOW)
  • if (( 40*ii+col+10 < SUP-20)&&(40*jj+lin+10 < SUP-20))
  • fillellipse(40*ii+col+10,40*jj+lin+10,8,8);
  • }
  • //""""""""""""""""""""""""""""""
  • void Virus::Add()
  • {
  • setcolor(14);
  • setfillstyle(SOLID_FILL,14);
  • pieslice(520,40+vie*30,20,350,10);
  • }
  • //-----------------------------------
  • void Virus::Cache()
  • {
  • int note=0;
  • //pieslice(x,y,30, 360, 9);
  • if ((getpixel(x,y)==9)||(getpixel(x,y)==15)){
  • if (getpixel(x,y)==15) note=1;
  • setfillstyle(SOLID_FILL, 0);
  • setcolor(0);
  • fillellipse(x,y,9,8);
  • setcolor(9);setfillstyle(SOLID_FILL,9);
  • if (note) {setcolor(15);setfillstyle(1,15);pieslice(x,y,0,360,3);}
  • pieslice(x,y,0,360,2);
  • }
  • else
  • {setfillstyle(SOLID_FILL, 0);
  • setcolor(0);
  • fillellipse(x,y,9,8);}
  • }
  • //-----------------------------------------
  • void Virus::Cache1()
  • {
  • setfillstyle(SOLID_FILL, 0);
  • setcolor(0);
  • //pieslice(x,y,30, 360, 9);
  • fillellipse(x,y,9,8);
  • }
  • //-------------------------------------------
  • //-----------------------------------
  • void Virus::Command(Virus p,int n)
  • {
  • int choix;
  • if (( x != p.lecX() ) || ( y != p.lecY() ))
  • {if (x != p.lecX())
  • {if (x < p.lecX()) {if (getpixel(x+12,y)!=YELLOW) choix=0;else if (getpixel(x,y-12)!=YELLOW) choix=3;}
  • else {if (getpixel(x-12,y)!=YELLOW) choix=1;else if(getpixel(x,y+12)!=YELLOW) choix=2;}}
  • else {if (y < p.lecY()) {if(getpixel(x,y+12)!=YELLOW) choix=2;else if (getpixel(x+12,y)!=YELLOW) choix=0;}
  • else {if (getpixel(x,y-12)!=YELLOW) choix=3;else if (getpixel(x-12,y)!=YELLOW) choix=1;}}
  • for (int l=1;l<=n;l++){
  • if (vrai){
  • switch(choix) {
  • case 0: Cache();
  • x+=10;
  • Affiche(0);
  • break;
  • case 1 : Cache();
  • x-=10;
  • Affiche(1);
  • break;
  • case 2 : Cache();
  • y+=10;
  • Affiche(2);
  • break;
  • case 3 : Cache();
  • y-=10;
  • Affiche(3);
  • break;
  • }
  • delay(4);
  • }
  • } }
  • else {vrai=0; demo_music_laser();}
  • }
  • void Virus::Command2(Virus p,int n)
  • {
  • int choix;
  • if ( (x!=p.lecX())||(y != p.lecY()) )
  • {if (y != p.lecY())
  • {if (y < p.lecY()) {if (getpixel(x,y+12)!=YELLOW) choix=2;else if (getpixel(x-12,y)!=YELLOW) choix=1;}
  • else {if (getpixel(x,y-12)!=YELLOW) choix=3;else if (getpixel(x+12,y)!=YELLOW) choix=0;}}
  • else {if (x < p.lecX()) {if(getpixel(x+12,y)!=YELLOW) choix=0;else if (getpixel(x,y-12)!=YELLOW) choix=3;}
  • else {if (getpixel(x-12,y)!=YELLOW) choix=1;else if (getpixel(x,y+12)!=YELLOW) choix=2;}}
  • for (int l=1;l<=n;l++){
  • if (vrai){
  • switch(choix) {
  • case 0: Cache();
  • x+=10;
  • Affiche(0);
  • break;
  • case 1 : Cache();
  • x-=10;
  • Affiche(1);
  • break;
  • case 2 : Cache();
  • y+=10;
  • Affiche(2);
  • break;
  • case 3 : Cache();
  • y-=10;
  • Affiche(3);
  • break;
  • }
  • delay(4);}}
  • } else {vrai=0; demo_music_laser();}
  • }
  • //---------------------------------
  • void Command1(Virus p1,Virus p2,Virus p3,Virus p4)
  • {
  • int c,v;
  • int slep=0;
  • char touche;
  • while((vrai) && (touche!=CR) && (cpt!=70))
  • {
  • touche=getch();
  • if (touche==0X00)
  • touche=getch();
  • //for (int t=1;t<=1;t++){
  • while(!kbhit()){
  • switch(touche) {
  • case DROIT: p1.Cache1();
  • if (getpixel(p1.lecX()+12,p1.lecY()) !=YELLOW){
  • if (p1.lecX() != SUP)
  • p1.Modifier(10,0);
  • else if (p1.lecX()==SUP)
  • p1.Modifier(-340,0);}
  • break;
  • case GAUCH : p1.Cache1();
  • if (getpixel(p1.lecX()-12,p1.lecY()) !=YELLOW) {
  • if (p1.lecX() != INF)
  • p1.Modifier(-10,0);
  • else if (p1.lecX()==INF)
  • p1.Modifier(340,0);}
  • break;
  • case BAS : p1.Cache1();
  • if(getpixel(p1.lecX(),p1.lecY()+12)!=YELLOW){
  • if (p1.lecY() != SUP)
  • p1.Modifier(0,10);
  • else if (p1.lecY()==SUP)
  • p1.Modifier(0,-340); }
  • break;
  • case HAUT : p1.Cache1();
  • if (getpixel(p1.lecX(),p1.lecY()-12)!=YELLOW) {
  • if (p1.lecY() != INF)
  • p1.Modifier(0,-10);
  • else if (p1.lecY()==INF)
  • p1.Modifier(0,340); }
  • break;
  • case ESC :exit(0);
  • }if (getpixel(p1.lecX(),p1.lecY())==9) p1.Compteur();
  • if (getpixel(p1.lecX(),p1.lecY())==15) slep=30;
  • if (getpixel(p1.lecX(),p1.lecY())==4) {p1.vieADD();p1.Add();}
  • p1.Affiche1(touche);delay(80);
  • if(slep==0){
  • p2.Command2(p1,1);p4.Command2(p1,1);p3.Command(p1,1);
  • if (cpt % 1 ==0) p1.Life();
  • } else {demo_music_ambilance();slep-=1;} }
  • while (!kbhit())
  • {p2.Command2(p1,1);p4.Command(p1,1);p3.Command2(p1,1);}
  • }p1.Cache1();
  • p2.Cache();
  • p3.Cache();
  • p4.Cache();
  • }
  • void Remplir_mat(int mat[18][18])
  • {
  • for(int i=0;i<18;i++) mat[i][0]=1;
  • for(int i1=0;i1<18;i1++) mat[0][i1]=1;
  • mat[0][8]=0;
  • for(int i2=0;i2<18;i2++) mat[i2][17]=1;
  • for(int i3=0;i3<18;i3++) mat[17][i3]=1;
  • mat[17][8]=0;
  • for(int i4=5;i4<=12;i4++) mat[i4][2]=1;
  • for(int i5=5;i5<=12;i5++) mat[i5][15]=1;
  • mat[3][2]=1;mat[3][3]=1;mat[2][3]=1;mat[1][1]=1;
  • mat[14][2]=1;mat[14][3]=1;mat[15][3]=1;mat[16][1]=1;
  • mat[5][4]=1;mat[6][4]=1;mat[7][4]=1;
  • mat[12][4]=1;mat[10][4]=1;mat[11][4]=1;
  • mat[12][13]=1;mat[10][13]=1;mat[11][13]=1;
  • mat[5][13]=1;mat[6][13]=1;mat[7][13]=1;
  • mat[1][5]=1;mat[1][6]=1;mat[1][7]=1;
  • mat[3][5]=1;mat[3][6]=1;mat[3][7]=1;
  • mat[14][5]=1;mat[14][6]=1;mat[14][7]=1;
  • mat[16][5]=1;mat[16][6]=1;mat[16][7]=1;
  • mat[1][9]=1;mat[1][10]=1;mat[1][11]=1;mat[1][12]=1;
  • mat[3][9]=1;mat[3][10]=1;mat[3][11]=1;mat[3][12]=1;
  • mat[14][9]=1;mat[14][10]=1;mat[14][11]=1;mat[14][12]=1;
  • mat[16][9]=1;mat[16][10]=1;mat[16][11]=1;mat[16][12]=1;
  • mat[1][16]=1;mat[16][16]=1;mat[8][6]=1;mat[8][11]=1;mat[9][6]=1;mat[9][11]=1;
  • mat[2][14]=1;mat[3][14]=1;mat[3][15]=1;
  • mat[15][14]=1;mat[14][14]=1;mat[14][15]=1;
  • mat[5][6]=1;mat[6][6]=1;mat[5][7]=1;
  • mat[11][6]=1;mat[12][6]=1;mat[12][7]=1;
  • mat[5][9]=1;mat[5][10]=1;mat[5][11]=1;mat[6][11]=1;
  • mat[12][9]=1;mat[12][10]=1;mat[12][11]=1;mat[11][11]=1;
  • }
  • void affiche_stage(int mat[18][18])
  • { setcolor(14);
  • setfillstyle(1,14);
  • for (int i=0;i<18;i++)
  • for (int j=0;j<18;j++)
  • if (mat[i][j]==1) bar3d(20*i+col,20*j+lin,20*i+col+20,20*j+lin+20,0,0);
  • }
  • void point_stage(int mat[18][18])
  • {
  • for (int i=0;i<18;i++)
  • for(int j=0;j<18;j++)
  • {if (mat[i][j]==0)
  • {setcolor(9);setfillstyle(SOLID_FILL,9);pieslice(20*i+col+10,20*j+lin+10,0,360,2);}}
  • setcolor(15);
  • setfillstyle(1,15);
  • pieslice(120,120,0,360,5);
  • pieslice(380,120,0,360,5);
  • pieslice(120,380,0,360,5);
  • pieslice(380,380,0,360,5);
  • for (int u=100;u<=160;u+=30 )
  • { setcolor(14);
  • setfillstyle(SOLID_FILL,14);
  • pieslice(520,u,20,350,10); }
  • }
  • //-----------------------------------
  • void main()
  • {
  • //cleardevice();
  • int gdriver = DETECT, gmode, errorcode;
  • initgraph(&gdriver, &gmode, "../bgi");
  • Virus p2(160,380,10,0),p3(340,380,4,0),p4(200,360,9,0);
  • Virus p1(300,100,15,4);
  • int u=100;
  • int mat[18][18]={0};
  • Remplir_mat(mat);
  • affiche_stage(mat);
  • point_stage(mat);
  • while((cpt!=100)&&(p1.lecVie()!=0))
  • {
  • Command1(p1,p2,p3,p4);
  • p1.vieSUB();
  • setcolor(0);
  • setfillstyle(SOLID_FILL,0);
  • pieslice(520,u,20,350,10);
  • u+=30;
  • vrai=1;
  • }
  • getch();
  • }
#include<stdlib.h>
#include<graphics.h>
#include<math.h>
#include<stdio.H>
#include<string.h>
#include<conio.h>
#include<dos.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       420
#define  INF       80
#define lin 70
#define col 70
int vrai=1;
int cpt=0;
int mat[18][18];
int u;
void affiche_stage(int mat[18][18]);
void point_stage(int mat[18][18]);
void Remplir_mat(int mat[18][18]);


class Virus
 {
     public :
		Virus(int,int,int,int);
		void Affiche(int);
		friend void Score();
		friend void demo_music_laser();
		void Cache();
		void Cache1();
		void Command(Virus,int);
		void Command2(Virus,int);

		friend void Command1(Virus,Virus,Virus,Virus);

		void Affiche1(char);
		void Life();
		void Add();
		void vieADD();
		void vieSUB();
		void Compteur();
		void Modifier(int,int);
		int lecX(){return x;}
		int lecY(){return y;}
		int lecVie(){return vie;}

     private :
       int x,y;int c,vie;

 };


//-----------------------------------
Virus::Virus(int x1,int y1,int c1,int v)
{
x=x1;
y=y1;
c=c1;
vie=v;

}
//-----------------------------------
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();

    }


//------------------------------------

void Virus::Compteur()
{
cpt+=1;
gotoxy(1,1);printf("SCORE : %d",cpt);
	 sound(7000);
	 delay(50);
	 nosound();

}
//-----------------------------------
//-----------------------------------
void Virus::Modifier(int x1,int y1)
{
x=(x+x1) ;
y=(y+y1) ;

}
void Virus::vieADD()
{
vie+=1;
}
void Virus::vieSUB()
{
vie-=1;
}
//-----------------------------------
void Virus::Affiche(int n)
{
setcolor(c);
  //arc (x,y-1,0,180,8);      //tete
  arc (x,y+4,-160,-20,4);      //bouche
  arc (x,y+3,35,145,10);
  setfillstyle(SOLID_FILL,15);
  setcolor(15);
  pieslice(x-4,y,0,360,3);           //lunette
  pieslice(x+4,y,0,360,3);



  setfillstyle(SOLID_FILL,0);       //
  setcolor(0);

  switch(n){
    case 0:   pieslice(x-3,y,0,360,2);
	      pieslice(x+7,y,0,360,2);
	      break;
    case 1:   pieslice(x-7,y,0,360,2);
	      pieslice(x+3,y,0,360,2);
	      break;
    case 2:   pieslice(x-5,y+3,0,360,2);
	      pieslice(x+5,y+3,0,360,2);
	      break;
    case 3:   pieslice(x-5,y-3,0,360,2);
	      pieslice(x+5,y-3,0,360,2);
	      break;
	  }


 }
//------------------------------------------
void Virus::Affiche1(char n)
{
setcolor(c);
setfillstyle(1,15);
pieslice(lecX(),lecY(),0, 360, 8);
floodfill(lecX(),lecY(),15);
delay(10);
setcolor(0);setfillstyle(1,0);
   switch(n){

   case DROIT  :pieslice(lecX(),lecY(),0,30,8);break;
   case HAUT   : pieslice(lecX(),lecY(),70,110,8);break;
   case BAS    : pieslice(lecX(),lecY(),-80,-120,8);break;
   case GAUCH  :  pieslice(lecX(),lecY(),160,210,8);break;
    }
}
//""""""""""""""""""""""""""""""""""
void Virus::Life()
{
int ii,jj;
//fillellipse(210,240,8,8);
setcolor(4);
setfillstyle(1,4);
randomize();
ii=rand() % 18;
jj=rand() % 18;

if (getpixel(40*ii+col+10,40*jj+lin+10)!=YELLOW)
   if (( 40*ii+col+10 < SUP-20)&&(40*jj+lin+10 < SUP-20))
	     fillellipse(40*ii+col+10,40*jj+lin+10,8,8);



}
//""""""""""""""""""""""""""""""
void Virus::Add()
{
setcolor(14);
    setfillstyle(SOLID_FILL,14);
    pieslice(520,40+vie*30,20,350,10);
}

//-----------------------------------
void Virus::Cache()
{
int note=0;
//pieslice(x,y,30, 360, 9);
if ((getpixel(x,y)==9)||(getpixel(x,y)==15)){
if (getpixel(x,y)==15) note=1;
setfillstyle(SOLID_FILL, 0);
setcolor(0);
fillellipse(x,y,9,8);
setcolor(9);setfillstyle(SOLID_FILL,9);
if (note) {setcolor(15);setfillstyle(1,15);pieslice(x,y,0,360,3);}
pieslice(x,y,0,360,2);
}


else
{setfillstyle(SOLID_FILL, 0);
setcolor(0);
fillellipse(x,y,9,8);}


}
//-----------------------------------------
void Virus::Cache1()
{
setfillstyle(SOLID_FILL, 0);
setcolor(0);
//pieslice(x,y,30, 360, 9);
fillellipse(x,y,9,8);

}




//-------------------------------------------
//-----------------------------------
void Virus::Command(Virus p,int n)
{

int choix;

 if (( x != p.lecX() ) || ( y != p.lecY() ))

    {if (x != p.lecX())
	 {if (x < p.lecX()) {if (getpixel(x+12,y)!=YELLOW) choix=0;else if (getpixel(x,y-12)!=YELLOW) choix=3;}
	 else {if (getpixel(x-12,y)!=YELLOW) choix=1;else if(getpixel(x,y+12)!=YELLOW) choix=2;}}

    else {if (y < p.lecY()) {if(getpixel(x,y+12)!=YELLOW) choix=2;else if (getpixel(x+12,y)!=YELLOW) choix=0;}
    else {if (getpixel(x,y-12)!=YELLOW) choix=3;else if (getpixel(x-12,y)!=YELLOW) choix=1;}}

for (int l=1;l<=n;l++){
if (vrai){
  switch(choix) {
		   case 0:         Cache();
				   x+=10;
				   Affiche(0);
				   break;
		   case 1 	:  Cache();


				   x-=10;


				   Affiche(1);
				   break;

		   case 2      :   Cache();


				   y+=10;


				   Affiche(2);
				   break;

		   case 3 	:  Cache();


				   y-=10;


				   Affiche(3);
				   break;
		 }

		 delay(4);
	     }
    } }
    else {vrai=0; demo_music_laser();}
}

void Virus::Command2(Virus p,int n)
{

int choix;

 if ( (x!=p.lecX())||(y != p.lecY()) )
       {if (y != p.lecY())
	 {if (y < p.lecY()) {if (getpixel(x,y+12)!=YELLOW) choix=2;else if (getpixel(x-12,y)!=YELLOW) choix=1;}
	 else {if (getpixel(x,y-12)!=YELLOW) choix=3;else if (getpixel(x+12,y)!=YELLOW) choix=0;}}

	 else {if (x < p.lecX()) {if(getpixel(x+12,y)!=YELLOW) choix=0;else if (getpixel(x,y-12)!=YELLOW) choix=3;}
	 else {if (getpixel(x-12,y)!=YELLOW) choix=1;else if (getpixel(x,y+12)!=YELLOW) choix=2;}}







for (int l=1;l<=n;l++){

if (vrai){
  switch(choix) {
		   case 0:         Cache();
				   x+=10;
				   Affiche(0);
				   break;
		   case 1 	:  Cache();
				   x-=10;
				   Affiche(1);
				   break;

		   case 2      :   Cache();
				   y+=10;
				   Affiche(2);
				   break;

		   case 3 	:  Cache();
				   y-=10;
				   Affiche(3);
				   break;
		 }

		 delay(4);}}
	     }  else {vrai=0; demo_music_laser();}



}
//---------------------------------
void Command1(Virus p1,Virus p2,Virus p3,Virus p4)
{
int c,v;
int slep=0;
char touche;
while((vrai) && (touche!=CR) && (cpt!=70))
{

touche=getch();
if (touche==0X00)
touche=getch();

//for (int t=1;t<=1;t++){
  while(!kbhit()){


	   switch(touche) {

		   case DROIT:    p1.Cache1();
				   if (getpixel(p1.lecX()+12,p1.lecY()) !=YELLOW){
				   if (p1.lecX() != SUP)
				   p1.Modifier(10,0);
				   else if (p1.lecX()==SUP)
				   p1.Modifier(-340,0);}

				   break;


		   case GAUCH 	:  p1.Cache1();
				    if (getpixel(p1.lecX()-12,p1.lecY()) !=YELLOW) {
				   if (p1.lecX() != INF)
				   p1.Modifier(-10,0);
				   else if (p1.lecX()==INF)
				   p1.Modifier(340,0);}



				   break;

		   case BAS      : p1.Cache1();
				   if(getpixel(p1.lecX(),p1.lecY()+12)!=YELLOW){
				   if (p1.lecY() != SUP)
				   p1.Modifier(0,10);
				   else if (p1.lecY()==SUP)
				   p1.Modifier(0,-340);  }



				   break;

		   case HAUT	:  p1.Cache1();
				   if (getpixel(p1.lecX(),p1.lecY()-12)!=YELLOW)  {
				   if (p1.lecY() != INF)
				   p1.Modifier(0,-10);
				   else if (p1.lecY()==INF)
				   p1.Modifier(0,340);  }



				   break;


		    case ESC        :exit(0);

		}if (getpixel(p1.lecX(),p1.lecY())==9) p1.Compteur();
		 if (getpixel(p1.lecX(),p1.lecY())==15) slep=30;
		 if (getpixel(p1.lecX(),p1.lecY())==4) {p1.vieADD();p1.Add();}
		p1.Affiche1(touche);delay(80);
		if(slep==0){
		 p2.Command2(p1,1);p4.Command2(p1,1);p3.Command(p1,1);
		 if (cpt % 1 ==0) p1.Life();
			}  else {demo_music_ambilance();slep-=1;} }

		while (!kbhit())
		  {p2.Command2(p1,1);p4.Command(p1,1);p3.Command2(p1,1);}




	}p1.Cache1();
	p2.Cache();
	p3.Cache();
	p4.Cache();
}
void Remplir_mat(int mat[18][18])
{

for(int i=0;i<18;i++) mat[i][0]=1;

for(int i1=0;i1<18;i1++) mat[0][i1]=1;
mat[0][8]=0;
for(int i2=0;i2<18;i2++) mat[i2][17]=1;
for(int i3=0;i3<18;i3++) mat[17][i3]=1;
mat[17][8]=0;
for(int i4=5;i4<=12;i4++) mat[i4][2]=1;
for(int i5=5;i5<=12;i5++) mat[i5][15]=1;
mat[3][2]=1;mat[3][3]=1;mat[2][3]=1;mat[1][1]=1;


mat[14][2]=1;mat[14][3]=1;mat[15][3]=1;mat[16][1]=1;
mat[5][4]=1;mat[6][4]=1;mat[7][4]=1;
mat[12][4]=1;mat[10][4]=1;mat[11][4]=1;
mat[12][13]=1;mat[10][13]=1;mat[11][13]=1;
mat[5][13]=1;mat[6][13]=1;mat[7][13]=1;
mat[1][5]=1;mat[1][6]=1;mat[1][7]=1;
mat[3][5]=1;mat[3][6]=1;mat[3][7]=1;
mat[14][5]=1;mat[14][6]=1;mat[14][7]=1;
mat[16][5]=1;mat[16][6]=1;mat[16][7]=1;
mat[1][9]=1;mat[1][10]=1;mat[1][11]=1;mat[1][12]=1;
mat[3][9]=1;mat[3][10]=1;mat[3][11]=1;mat[3][12]=1;
mat[14][9]=1;mat[14][10]=1;mat[14][11]=1;mat[14][12]=1;
mat[16][9]=1;mat[16][10]=1;mat[16][11]=1;mat[16][12]=1;
mat[1][16]=1;mat[16][16]=1;mat[8][6]=1;mat[8][11]=1;mat[9][6]=1;mat[9][11]=1;
mat[2][14]=1;mat[3][14]=1;mat[3][15]=1;
mat[15][14]=1;mat[14][14]=1;mat[14][15]=1;
mat[5][6]=1;mat[6][6]=1;mat[5][7]=1;
mat[11][6]=1;mat[12][6]=1;mat[12][7]=1;
mat[5][9]=1;mat[5][10]=1;mat[5][11]=1;mat[6][11]=1;
mat[12][9]=1;mat[12][10]=1;mat[12][11]=1;mat[11][11]=1;

}
void affiche_stage(int mat[18][18])
{ setcolor(14);

setfillstyle(1,14);
   for (int i=0;i<18;i++)
      for (int j=0;j<18;j++)
	if (mat[i][j]==1) bar3d(20*i+col,20*j+lin,20*i+col+20,20*j+lin+20,0,0);

}
void point_stage(int mat[18][18])
{

for (int i=0;i<18;i++)
  for(int j=0;j<18;j++)
     {if (mat[i][j]==0)
     {setcolor(9);setfillstyle(SOLID_FILL,9);pieslice(20*i+col+10,20*j+lin+10,0,360,2);}}
   setcolor(15);
setfillstyle(1,15);
pieslice(120,120,0,360,5);
pieslice(380,120,0,360,5);
pieslice(120,380,0,360,5);
pieslice(380,380,0,360,5);
for (int u=100;u<=160;u+=30 )
{   setcolor(14);
    setfillstyle(SOLID_FILL,14);
    pieslice(520,u,20,350,10);   }

}





//-----------------------------------
void main()
{
//cleardevice();
int gdriver = DETECT, gmode, errorcode;
initgraph(&gdriver, &gmode, "../bgi");
Virus p2(160,380,10,0),p3(340,380,4,0),p4(200,360,9,0);
Virus p1(300,100,15,4);
int u=100;
int mat[18][18]={0};
Remplir_mat(mat);

affiche_stage(mat);
point_stage(mat);

while((cpt!=100)&&(p1.lecVie()!=0))
{
  Command1(p1,p2,p3,p4);
    p1.vieSUB();
    setcolor(0);
    setfillstyle(SOLID_FILL,0);
    pieslice(520,u,20,350,10);
    u+=30;
    vrai=1;
       }





getch();

}



 Sources du même auteur

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

 Sources de la même categorie

Source avec Zip Source avec une capture PLANNING D'EQUIPE par grephit
Source avec Zip APPLICATION DE DESSIN DE QUELQUES FIGURES par laguchori
Source avec Zip Source avec une capture HDR EXPOSURE FUSION par mecrosoft
Source avec Zip Source avec une capture IRC CLIENT MULTISERVEUR EN MFC (TXIRC) par TeniX
Source avec Zip ENTETE DU FICHIER BMP (BIPMAP) par k.Lutchi

Commentaires et avis

Commentaire de shenron666 le 29/04/2005 12:17:46

Pas de zip...
Ce serai un minimum non ?

aller, un pti zip stp

si possible avec un exe en release (ca prend moins de place et ca évite d'avoir à compiler pour tester)

Commentaire de MoDDiB le 29/04/2005 13:07:27

Sans commentaire ton post est inutile pour une initiation tout court .
Et pour le orienté objet avec une seule classe je ne crois pas que ca soit une bonne initiation :(
Allez corrige ça je mettrais une note quand ca sera corrigé pour t'encourager   :)

Commentaire de goundy05 le 29/04/2005 16:28:14

mais c'est quoi ces gens mal "elevé". pffffffffffffffff
il a proposer un truck et tu le critique comme sa ?
c'est vrais que ta le droit de critiquer sa source mais pas de cette maniere la comme si toi tu est le grand meilleur et lui le petit apprenti , quoi tu trouve que tu vaux plus que les autres? unpeu de respect et reste sage parceque sa peut t'arrive en vrai mais la tu risque de tomber sur des gens qui tolere pas ta race ( c'est pas du racisme mais je veux dire les gens comme toi par le mot "race") desolé a tous pour se poste inutile pour certins mais utiles pour la races: ''je suis .. . .je suis . . .''

Commentaire de Kirua le 29/04/2005 17:24:01

Goundy, sérieusement, t'avais envie de te payer quelqu'un ajd, c'est ça? C'est objectif ce que dit MoDDiB: une seule classe, c'est maigre pour prétendre au cours de POO, et sans commentaire, c'est maigre pour prétendre à un cours tout court. Logique non? De plus, un jeu sans zip ni screenshot (même pour de la console), c'est contre indiqué.

Et je ne tiens vrmnt pas à subir une infinitième discussion stérile sur "c'était un bon comment" >< "non, c'était pas un bon comment".

Commentaire de goundy05 le 30/04/2005 00:24:31

pffffffffffffffffffff , tu la mal pris
ecoute mec je lui est di que sa facon de critiquer a été unpeu forte quoi , faut respecter les autre t'imagine quand l'auteur lira se commentaire il se sentira blessé quoi
sinon je croi qu'on se connai kirua ????

Commentaire de Kirua le 30/04/2005 11:52:26

C'est possible qu'on se connaisse, t'étais à prologin cette année? On va pas en discuter ici.

Quant à l'auteur, s'il se sent blessé pour si peu ... enfin, je pense qu'il est au dessus de tout ça quand même.

Commentaire de goundy05 le 30/04/2005 18:16:01

lol bon ben on va pas s'embrouiller pour sa , sinon je dit pas qu'on se connais en vrais mdrrr , mais si je me trompe pas tu est de alt-reality non?
on cause sur msn si tu veux :)
j'attend ta reponse (k)

Commentaire de Kirua le 30/04/2005 18:22:38

(désolé pour la pollution du poste :/)
non je suis pas sur alt reality, je sais même pas ce que c'est ^^

Commentaire de MoDDiB le 01/05/2005 13:43:10

Pollueurs Kirua :p
"Allez corrige ça je mettrais une note quand ca sera corrigé pour t'encourager   :)"
Si ca c'est du cassage et si ce que j'ai dis c'est pas constructif j'y comprends plus rien !
Ensuite  tu ne me connais pas je ne te permet donc pas de me juger sur ce commentaire constructif tout comme je ne te jugerai pas pour ton comportement qui est du a un malentendu...

Commentaire de goundy05 le 01/05/2005 16:27:09

alaise j'ai rein dit xD
et si ca t'a gener je m'excuse :)

Commentaire de MoDDiB le 01/05/2005 17:37:30

Excuses acceptées , tu devais être fatigué  :) @+

Commentaire de MoDDiB le 02/05/2005 21:17:12

Cool ne t'inquietes pas tout ce qu'on souhaite c'est que tu t'améliore et que tu puisse toi aussi contribuer a l'utilité du site :)

Commentaire de xmenneo2003 le 02/05/2005 21:17:34

les mecs c'est mon premier programme j'avais pas le temps pour mettre des comentere je m'exuse
bientot je vais remettre la version complete
   vous aller etre etonner

Commentaire de goundy05 le 03/05/2005 00:36:31

on a compri qd meme :o

Commentaire de aminco le 07/05/2005 21:33:29

c'est un tres bon travail realiser par un eleve de 1 anne inpformatique .
c'set bien je vous felicite mon amie
et ne t'inquiete pas un bon programmeur c'est celui qui
rest a la fin sur le terrain de la gerre des ^programmes performant.

Commentaire de wxccxw le 11/06/2006 17:34:22

enfin ya aussi la fonction edit ;)

 Ajouter un commentaire




Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Mai 2012
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

Consulter la suite du CalendriCode

A découvrir



 
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 : 0,655 sec (3)

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