begin process at 2012 05 27 18:45:16
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Jeux

 > MORBAK

MORBAK


 Information sur la source

Note :
Aucune note
Catégorie :Jeux Niveau :Débutant Date de création :01/11/2002 Date de mise à jour :01/11/2002 15:05:57 Vu :2 584

Auteur : skinia

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

 Description

Cliquez pour voir la capture en taille normale
morbak

Source

  • #include <stdio.h>
  • #include <conio.c>
  • #include <time.h>
  • void intro();
  • void TEXTE(int couleur, int col, int ligne, char *texte);
  • void dessine_cadre();
  • void jeu();
  • int verifie_casjoueur(int t[],int cas,int N);
  • void fin(int v[],int x);
  • int main(){
  • intro();
  • jeu();
  • }
  • void intro(){
  • int l,m,n;
  • for(l = n = 19,m = 1;l >= 10;l--,m++,n--){
  • clrscr();
  • TEXTE(m,l,13,"|\\ /| ____ ____ ___ * ____ ");
  • TEXTE(m,m,14,"| \\/ | | | |____| |___| | | | |\\ |");
  • TEXTE(m,n,15,"| | |____| | \\ | | |____| | \\|");
  • sleep(100);
  • }
  • sleep(500);
  • }
  • void TEXTE(int couleur, int col, int ligne, char *texte){
  • textcolor(couleur);
  • gotoxy(col,ligne);
  • printf("%s",texte);
  • return;
  • }
  • /*******************************************************************/
  • /******************** fonction qui dessine le cadre du jeu ****************/
  • /*******************************************************************/
  • void dessine_cadre(){
  • int i;
  • clrscr();
  • textcolor(LIGHTGREEN);
  • for(i=3;i<24;i++){
  • gotoxy(41,i);
  • printf("\xB3");
  • gotoxy(59,i);
  • printf("\xB3");
  • sleep(10);
  • }
  • for(i=32;i<70;i++){
  • gotoxy(i,8);
  • printf("\xC4");
  • gotoxy(i,18);
  • printf("\xC4");
  • sleep(10);
  • }
  • gotoxy(41,8);printf("\xC5");
  • gotoxy(59,8);printf("\xC5");
  • gotoxy(41,18);printf("\xC5");
  • gotoxy(59,18);printf("\xC5");
  • gotoxy(35,5);printf("1");
  • gotoxy(50,5);printf("2");
  • gotoxy(65,5);printf("3");
  • gotoxy(35,13);printf("4");
  • gotoxy(50,13);printf("5");
  • gotoxy(65,13);printf("6");
  • gotoxy(35,21);printf("7");
  • gotoxy(50,21);printf("8");
  • gotoxy(65,21);printf("9");
  • gotoxy(1,24);textcolor(LIGHTGREEN);printf("joueur 1: ");
  • gotoxy(11,24);textcolor(LIGHTRED);printf("X");
  • gotoxy(1,25);textcolor(LIGHTGREEN);printf("joueur 2: ");
  • gotoxy(11,25);textcolor(LIGHTBLUE);printf("O");
  • textcolor(LIGHTGREEN);
  • gotoxy(1,1);
  • }
  • /**********************************************************************/
  • /***************************** fonction du jeu **************************/
  • /**********************************************************************/
  • void jeu(){
  • int ncase,i,encore=0,cases_jouees[9],ver[9];
  • dessine_cadre();
  • for(i=1;i<=9;i++){
  • ver[i]=0;
  • }
  • cases_jouees[1]=0;
  • while(encore<8){
  • encore++;
  • textcolor(LIGHTGREEN);
  • do{
  • gotoxy(1,1);
  • printf("Joueur 1 : Quelle case ?\n<1,...,9>>");
  • scanf("%d",&ncase);
  • gotoxy(11,2);printf(" ");
  • gotoxy(1,3);printf(" ");
  • }while(verifie_casjoueur(cases_jouees,ncase,encore));
  • cases_jouees[encore]=ncase;
  • ver[ncase]=1;
  • textcolor(LIGHTRED);
  • switch(ncase)
  • {
  • case 1:gotoxy(35,5);printf("X");break;
  • case 2:gotoxy(50,5);printf("X");break;
  • case 3:gotoxy(65,5);printf("X");break;
  • case 4:gotoxy(35,13);printf("X");break;
  • case 5:gotoxy(50,13);printf("X");break;
  • case 6:gotoxy(65,13);printf("X");break;
  • case 7:gotoxy(35,21);printf("X");break;
  • case 8:gotoxy(50,21);printf("X");break;
  • case 9:gotoxy(65,21);printf("X");break;
  • default:break;
  • }
  • fin(ver,3);
  • encore++;
  • textcolor(LIGHTGREEN);
  • do{
  • gotoxy(1,1);
  • printf("Joueur 2 : Quelle case ?\n<1,...,9>>");
  • scanf("%d",&ncase);
  • gotoxy(11,2);printf(" ");
  • gotoxy(1,3);printf(" ");
  • }while(verifie_casjoueur(cases_jouees,ncase,encore));
  • gotoxy(5,20);printf(" ");
  • cases_jouees[encore]=ncase;
  • ver[ncase]=2;
  • textcolor(LIGHTBLUE);
  • switch(ncase)
  • {
  • case 1:gotoxy(35,5);printf("O");break;
  • case 2:gotoxy(50,5);printf("O");break;
  • case 3:gotoxy(65,5);printf("O");break;
  • case 4:gotoxy(35,13);printf("O");break;
  • case 5:gotoxy(50,13);printf("O");break;
  • case 6:gotoxy(65,13);printf("O");break;
  • case 7:gotoxy(35,21);printf("O");break;
  • case 8:gotoxy(50,21);printf("O");break;
  • case 9:gotoxy(65,21);printf("O");break;
  • default:break;
  • }
  • fin(ver,6);
  • }
  • gotoxy(1,10);printf("match nul");
  • getch();getch();
  • jeu();
  • }
  • /***********************************************************************/
  • /****************** fonctions qui verifient si le coup est bon ******************/
  • /***********************************************************************/
  • int verifie_casjoueur(int t[],int cas,int N){
  • int i,mauvais=0,m=0;
  • for(i=1;i<=N;i++)
  • {
  • if(cas==t[i] || cas<1 || cas>9) mauvais++;
  • }
  • return(mauvais);
  • }
  • void fin(int v[],int x){
  • int m=0;
  • if(v[1]+v[2]+v[3]==x && v[1]!=0 && v[2]!=0 && v[3]!=0) m=x/3;
  • if(v[4]+v[5]+v[6]==x && v[4]!=0 && v[5]!=0 && v[6]!=0) m=x/3;
  • if(v[7]+v[8]+v[9]==x && v[7]!=0 && v[8]!=0 && v[9]!=0) m=x/3;
  • if(v[1]+v[4]+v[7]==x && v[1]!=0 && v[4]!=0 && v[7]!=0) m=x/3;
  • if(v[2]+v[5]+v[8]==x && v[2]!=0 && v[5]!=0 && v[8]!=0) m=x/3;
  • if(v[3]+v[6]+v[9]==x && v[3]!=0 && v[6]!=0 && v[9]!=0) m=x/3;
  • if(v[1]+v[5]+v[9]==x && v[1]!=0 && v[5]!=0 && v[9]!=0) m=x/3;
  • if(v[7]+v[5]+v[3]==x && v[7]!=0 && v[5]!=0 && v[3]!=0) m=x/3;
  • if(m){
  • gotoxy(1,10);printf("joueur %d gagne",m);
  • getch();getch();
  • jeu();
  • }
  • }
#include <stdio.h>
#include <conio.c>
#include <time.h>

void intro();
void TEXTE(int couleur, int col, int ligne, char *texte);
void dessine_cadre();
void jeu();
int verifie_casjoueur(int t[],int cas,int N);
void fin(int v[],int x);

int main(){
    intro();
    jeu();
}


void intro(){
    int l,m,n;
    for(l = n = 19,m = 1;l >= 10;l--,m++,n--){
      clrscr();
      TEXTE(m,l,13,"|\\  /|   ____    ____     ___   *   ____        ");
      TEXTE(m,m,14,"| \\/ |  |    |  |____|   |___|  |  |    |  |\\ |");
      TEXTE(m,n,15,"|    |  |____|  |     \\  |      |  |____|  | \\|");
      sleep(100);
    }
      sleep(500);
}

void TEXTE(int couleur, int col, int ligne, char *texte){
    textcolor(couleur);
    gotoxy(col,ligne);
    printf("%s",texte);
    return;
}


/*******************************************************************/
/********************  fonction qui dessine le cadre du jeu  ****************/
/*******************************************************************/

void dessine_cadre(){
    int i;
    clrscr();
    textcolor(LIGHTGREEN);
    for(i=3;i<24;i++){
      gotoxy(41,i);
      printf("\xB3");
      gotoxy(59,i);
      printf("\xB3");
      sleep(10);
    }
    for(i=32;i<70;i++){
      gotoxy(i,8);
      printf("\xC4");
      gotoxy(i,18);
      printf("\xC4");
      sleep(10);
    }
    gotoxy(41,8);printf("\xC5");
    gotoxy(59,8);printf("\xC5");
    gotoxy(41,18);printf("\xC5");
    gotoxy(59,18);printf("\xC5");
    gotoxy(35,5);printf("1");
    gotoxy(50,5);printf("2");
    gotoxy(65,5);printf("3");
    gotoxy(35,13);printf("4");
    gotoxy(50,13);printf("5");
    gotoxy(65,13);printf("6");
    gotoxy(35,21);printf("7");
    gotoxy(50,21);printf("8");
    gotoxy(65,21);printf("9");
    gotoxy(1,24);textcolor(LIGHTGREEN);printf("joueur 1: ");
    gotoxy(11,24);textcolor(LIGHTRED);printf("X");
    gotoxy(1,25);textcolor(LIGHTGREEN);printf("joueur 2: ");
    gotoxy(11,25);textcolor(LIGHTBLUE);printf("O");
    textcolor(LIGHTGREEN);
    gotoxy(1,1);
}



/**********************************************************************/
/*****************************  fonction du jeu  **************************/
/**********************************************************************/

void jeu(){
    int ncase,i,encore=0,cases_jouees[9],ver[9];
    dessine_cadre();
    for(i=1;i<=9;i++){
      ver[i]=0;
    }
    cases_jouees[1]=0;
    while(encore<8){
      encore++;
      textcolor(LIGHTGREEN);
      do{
       gotoxy(1,1);
       printf("Joueur 1 : Quelle case ?\n<1,...,9>>");
       scanf("%d",&ncase);
       gotoxy(11,2);printf("         ");
       gotoxy(1,3);printf("          ");
      }while(verifie_casjoueur(cases_jouees,ncase,encore));
      cases_jouees[encore]=ncase;
      ver[ncase]=1;
      textcolor(LIGHTRED);
      switch(ncase)
      {
      case 1:gotoxy(35,5);printf("X");break;
      case 2:gotoxy(50,5);printf("X");break;
      case 3:gotoxy(65,5);printf("X");break;
      case 4:gotoxy(35,13);printf("X");break;
      case 5:gotoxy(50,13);printf("X");break;
      case 6:gotoxy(65,13);printf("X");break;
      case 7:gotoxy(35,21);printf("X");break;
      case 8:gotoxy(50,21);printf("X");break;
      case 9:gotoxy(65,21);printf("X");break;
      default:break;
      }
      fin(ver,3);
      encore++;
      textcolor(LIGHTGREEN);
      do{
       gotoxy(1,1);
       printf("Joueur 2 : Quelle case ?\n<1,...,9>>");
       scanf("%d",&ncase);
       gotoxy(11,2);printf("         ");
       gotoxy(1,3);printf("          ");
      }while(verifie_casjoueur(cases_jouees,ncase,encore));
      gotoxy(5,20);printf("            ");
      cases_jouees[encore]=ncase;
      ver[ncase]=2;
      textcolor(LIGHTBLUE);
      switch(ncase)
      {
      case 1:gotoxy(35,5);printf("O");break;
      case 2:gotoxy(50,5);printf("O");break;
      case 3:gotoxy(65,5);printf("O");break;
      case 4:gotoxy(35,13);printf("O");break;
      case 5:gotoxy(50,13);printf("O");break;
      case 6:gotoxy(65,13);printf("O");break;
      case 7:gotoxy(35,21);printf("O");break;
      case 8:gotoxy(50,21);printf("O");break;
      case 9:gotoxy(65,21);printf("O");break;
      default:break;
      }
      fin(ver,6);
    }
    gotoxy(1,10);printf("match nul");
    getch();getch();
    jeu();
}

/***********************************************************************/
/******************  fonctions qui verifient si le coup est bon  ******************/
/***********************************************************************/

int verifie_casjoueur(int t[],int cas,int N){
    int i,mauvais=0,m=0;
    for(i=1;i<=N;i++)
    {
    if(cas==t[i] || cas<1 || cas>9) mauvais++;
    }
    return(mauvais);
}

void fin(int v[],int x){
      int m=0;
      if(v[1]+v[2]+v[3]==x && v[1]!=0 && v[2]!=0 && v[3]!=0) m=x/3;
      if(v[4]+v[5]+v[6]==x && v[4]!=0 && v[5]!=0 && v[6]!=0) m=x/3;
      if(v[7]+v[8]+v[9]==x && v[7]!=0 && v[8]!=0 && v[9]!=0) m=x/3;
      if(v[1]+v[4]+v[7]==x && v[1]!=0 && v[4]!=0 && v[7]!=0) m=x/3;
      if(v[2]+v[5]+v[8]==x && v[2]!=0 && v[5]!=0 && v[8]!=0) m=x/3;
      if(v[3]+v[6]+v[9]==x && v[3]!=0 && v[6]!=0 && v[9]!=0) m=x/3;
      if(v[1]+v[5]+v[9]==x && v[1]!=0 && v[5]!=0 && v[9]!=0) m=x/3;
      if(v[7]+v[5]+v[3]==x && v[7]!=0 && v[5]!=0 && v[3]!=0) m=x/3;
      if(m){
        gotoxy(1,10);printf("joueur %d gagne",m);
        getch();getch();
        jeu();
      }
}

 Conclusion

morbak


 Sources du même auteur

Source avec Zip SHOOT 2D POLITIQUE : LA REVANCHE DE L.J
Source avec Zip Source avec une capture CASSE BRIQUE SOUS DEV CPP (POUR PASSER LE TEMPS PENDANT MON ...
Source avec Zip Source avec une capture PUISSANCE 4 GRAPHIQUE EN MODE DOS AVEC IA IMBATTABLE
PROG QUI CALCULE LE NB DE LIGNE D'UN CODE(AVEC COMMENTAIRES,...
Source avec Zip Source avec une capture SUPER MASTERMIND EN MODE GRAPHIQUE

 Sources de la même categorie

Source avec Zip Source avec une capture JEU DES CARTES par eapaceinfo
PROGRAMME DE JEU DE MPT par KerizGarmm
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

Commentaires et avis

Commentaire de cmarsc le 02/11/2002 18:36:09

salut,

dans tes prototypes sans arguments tu devrais mettre void par exemple :
void intro(void);
int main(void)  (return 0;)

de plus on ne peut pas sortir proprement du programme avec un ESC il faut passer
par les grands moyens.

tu retournes parfois return; et dans d'autres situations rien alors qu'il faut
en mettre un bien que certains compilateurs n'émettent pas de messages d'erreurs.

#include &lt;time.h&gt; ? il n'est pas utilisé
pour faire des espaces il y a une solution plus simple on veut 6 espaces vides
printf("%6c",'');

cmarsc

Commentaire de cmarsc le 02/11/2002 18:41:57

j'avais mis printf("%6c",NULL); mais il ne s'affiche pas bien

Commentaire de skinia le 03/11/2002 10:29:59

merci pour les conseils
mais en fait le prog a un bug: qnd le joueur rentre une lettre ca fait planter le prog
on peut ptetr fair qqch

 Ajouter un commentaire




Nos sponsors


Sondage...

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,593 sec (3)

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