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 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
| #include <stdio.h>
#include <conio.h>
#include<string.h>
#include <windows.h>
#include<time.h>
#define MAX 8
#define MIN 1
#define M 18
#define m 1
/* perso est represente par un "X" */
/* zone de jeu = 20 en horizontale * 40 en vertical */
/*________________________________________________________________________*/
char phant = 'O';
char perso ='X';
char table[10][20];
int x=1;
int y=1;
int a=1;
int j,i;
int b=18;
int c=8;
int d=1;
int e=8;
int f=18;
// fonction couleur //
//..........................................................................................//
void color(int couleurDuTexte,int couleurDeFond)
{
HANDLE H=GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(H,couleurDeFond*16+couleurDuTexte);
}
/*_______________________________________________________________________*/
/* fonction construisant l'arene */
/*_______________________________________________________________________*/
void arene (){
/* bord du haut */
for (j=0;j<20;j++){
table[0][j]='#';
}
/* bord du bas */
for (j=0;j<20;j++){
table[9][j]='#';
}
/* bord gauche */
for (i=1;i<9;i++){
table[i][0]='#';
}
/* bord de droite */
for (i=1;i<9;i++){
table[i][19]='#';
}
/* interieur : on rempli l'interieur avec des points */
for (i=1;i<9;i++){
for (j=1;j<19;j++){
table[i][j]='.';
}
}
/* personnage a l'origine */
table[y][x]=perso;
}
/*_____________________________________________________________________*/
/* affiche arene */
/*_____________________________________________________________________*/
void affiche (){
color(1,0);
for(i=0;i<10;i++){
for(j=0;j<20;j++){
printf("%c",table[i][j]);
}
printf("\n" );
}
color(15,0);
}
//-------------------------------------------------------------------//
// afficher les phantomes //
//-------------------------------------------------------------------//
void phantome()
{
table[a][b]=phant;
table[c][d]=phant;
table[e][f]=phant;
}
int affichageMenu()
{
int choixMenu;
color(3,0);
printf("--------------------Menu-------------\n\n");
color(15,0);
printf("1.Start!\n\n");
printf("2.Instruction !\n\n");
printf("3.Présentation du jeu !\n\n");
printf("4.Quitterr!\n\n\n");
color(3,0);
printf("\nVotre choix?\n\n");
scanf("%d", &choixMenu);
color(15,0);
return choixMenu;
}
/*_______________________________________________________________________*/
/* fonction principale */
/*_______________________________________________________________________*/
int main (){
char choix_deplac;
srand(time(NULL));
int score=0;
char tabl[100];
color(14,0);
printf("000000000 000000000 00000000 0000 000 000 0000000 0000 00 \n");
printf("00 00 00 00 00 00000 000 0000 00 00 00 0 00 \n");
printf("00 00 00 00 00 000 0 000 0 000 00 00 00 0 00 \n");
printf("0000000000 000000000 00 000 0000 0 000 0000000 00 0 00 \n");
printf("00 00 00 00 000 000 000 00 00 00 0 00 \n");
printf("00 00 00 00 000 000 00 00 00 0 00 \n");
printf("00 00 00 0000000 000 000 00 00 00 0000 \n");
printf(" \n\n\n");
switch(affichageMenu())
{
case 1:
printf("Entrer Votre Nom \n");
scanf("%s", tabl);
printf("\n");
while (-1){
color(2,0);
printf("------------------------------------------------\n");
printf("------------------PACMAN------------------------\n");
printf("------------------------------------------------\n");
color(15,0);
printf("\n");
choix_deplac=getch();
switch (choix_deplac){
case 72 : {table[y][x]=' ';
y--;
score++;
}
break;
case 80 :{ table [y][x]=' ';
y++;
score++;
}
break;
case 75 : {table [y][x]=' ';
x--;
score++;
}
break;
case 77 :{ table [y][x]=' ';
x++;
score++;}
break;
}
if(table[y][x]== '#')
{
printf(" GAME OVER \n");
puts(tabl);
printf(" votre score est %d\n",score-1);
printf("\n");
printf(" a la prochaine ");
printf("\n");
break;
}
if(table[y][x]== phant)
{
printf(" GAME OVER \n");
puts(tabl);
printf(" votre score est %d\n",score-1);
printf("\n");
printf(" a la prochaine ");
printf("\n");
break;
}
a = (rand() % (MAX - MIN + 1)) + MIN;
b= (rand() % (M- m + 1)) + m;
e = (rand() % (MAX - MIN + 1)) + MIN;
f= (rand() % (M- m + 1)) + m;
c= (rand() % (MAX - MIN + 1)) + MIN;
d= (rand() % (M- m + 1)) + m;
arene();
phantome();
affiche();
}
break;
case 2:
color(11,0);
printf(" \n");
printf(" \n");
printf(" --------------LES INSTRUCTIONS---------------------\n");
printf("-----------------------------------------------------\n");
printf("\n\n vous pouvez utiliser les touches directionnelles pour faire deplacer votre PACMAN, ainsi pour vous ne devez pas entrer en collision avec les murs qui constituent l'arene \n" );
printf("-----------------------------------------------------\n");
color(15,0);
break;
case 3:
printf("Notre jeu s inspire fortement du celebre jeu d arcade Pac-Man, sorti par Namco en 1979. Les regles de notre jeu sont donc inspire du jeu original a quelques détails pres. Le but du jeu consiste a deplacer un personnage nomme PACMAN à l interieur d une ARENE afin d'avoir avoir des points (1 point est egal a un seul deplacement)");
break;
case 4:
printf("BYE BYE\n");
break;;
default:
printf("Vous ne ferez rien du tout!");
break;
}
getch();
return 0;
} |
Partager