1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
void board (char tab1[5][5],char tab2[5][5],char tabE[5],char tabR[5]);
void player1();
void player2();
void montagne();
void menu()
{
int choix, solo;
printf("Que voulez vous faire ?\n1. Jouer\n2. Lire les regles\n3. Quitter\n");
scanf("%d", &choix);
while ((choix != 1) && (choix != 2) && (choix !=3 ))
{
printf("Erreur, veuillez recommencer\n");
scanf("%d", &choix);
}
if (choix == 1)
{
printf("Jouer a deux ou contre l'ordinateur ?\n");
scanf("%d", &solo);
while ((choix != 1) && (choix != 2))
{
printf("Erreur\n");
scanf("%d", &solo);
}
if (solo == 1)
{
return 0;
}
if (solo == 2)
{
return 0;
}
}
if (choix == 2)
{
printf("Chaque joueur choisit son animal. Les joueurs joueront a tour de role. Au debut du jeu les animaux sont disposes a l'exterieur du plateau et les montagnes au centre du plateau. Chaque case du plateau est reperee par ses coordonnees :\n ligne A a E, colonne 1 a 5. Les elephants blancs, animaux sacres dans le royaume de SIAM commenceront a jouer.\n");
}
if (choix == 3)
{
return 0;
}
}
void player1(char tab1[5][5],char tab2[5][5]) //spgrm placement du joeur 1
{
int ver,hor; ///variables qui désignes la ligne horizontale et veriticale du tab1
char orientation; /// variable qui permet de metttre l'orientation du pion
printf("saisir coordonnees case\n");
scanf("%d ",&ver);
scanf("%d",&hor);
scanf("%c",&tab1[ver][hor]); /// je met ça car je sais pas comment mettre le E d'office dans ces coordonées là
printf("choisir direction \n");
scanf("%c",orientation);
scanf("%c",&tab2[ver][hor]); /// je met l'orientation souhaitée dans le tableau
}
void board (char tab1[5][5],char tab2[5][5],char tabE[5],char tabR[5]) //sous programme pour afficher le tableau de jeu
{
int a=0;
int i=0;
int j=0;
int h=0;
printf(" +--+--+--+--+--+\n |1 |2 |3 |4 |5 |\n +--+--+--+--+--+\n");
printf(" ");
for(a=0; a<5; a++)
{
printf("|%c ",tabE[a]);
}
printf("|\n");
printf(" +--+--+--+--+--+\n\n");
for (i=0; i<5; i++)
{
printf("+--+--+ ");
for (j=0; j<5; j++)
{
printf("+--");
}
printf("+\n");
printf("|%c |%c |",(65+i),tabR[i]);
printf(" ");
for (h=0; h<5; h++)
{
printf("|%c%c",tab1[i][h],tab2[i][h]);
}
printf("|\n");
}
printf("+--+--+ +--+--+--+--+--+\n");
}
int main()
{
char tab1[5][5]= {{' ',' ',' ',' ',' '},{' ',' ',' ',' ',' '},{' ',' ',' ',' ',' '},{' ',' ',' ',' ',' '},{' ',' ',' ',' ',' '}};
char tab2[5][5]= {{' ',' ',' ',' ',' '},{' ',' ',' ',' ',' '},{' ',' ',' ',' ',' '},{' ',' ',' ',' ',' '},{' ',' ',' ',' ',' '}};
char tabE[5]= {'E','E','E','E','E'};
char tabR[5]= {'R','R','R','R','R'};
board(tab1,tab2,tabE,tabR);
menu();
return 0;
} |
Partager