2024-10-25 13:08:43 +02:00
|
|
|
#include <graph.h>
|
2024-11-18 17:18:12 +01:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
2024-11-20 15:01:35 +01:00
|
|
|
|
|
|
|
|
#include "menu.h"
|
|
|
|
|
#include "comportementJCJ.h"
|
|
|
|
|
#include "comportementJCIA.h"
|
2024-11-11 14:47:28 +01:00
|
|
|
|
2024-10-25 13:08:43 +02:00
|
|
|
int main (void){
|
2024-11-20 14:10:43 +01:00
|
|
|
int victoire = 0, choix = 0, SourisX = 0, SourisY = 0;
|
2024-10-29 13:32:57 +01:00
|
|
|
InitialiserGraphique();
|
2024-11-12 23:57:03 +01:00
|
|
|
CreerFenetre(50, 50, 700, 500); /* Initialise la fenetre puis lance le programme jeu.c qui lancera d'autre programme */
|
2024-11-18 17:18:12 +01:00
|
|
|
while(1){
|
2024-11-20 14:10:43 +01:00
|
|
|
choix = 0;
|
|
|
|
|
SourisX = 0;
|
|
|
|
|
SourisY = 0;
|
2024-11-18 17:18:12 +01:00
|
|
|
EffacerEcran(CouleurParNom("white"));
|
|
|
|
|
victoire = Jeu();
|
|
|
|
|
FermerGraphique();
|
|
|
|
|
InitialiserGraphique();
|
|
|
|
|
CreerFenetre(50, 50, 700, 500);
|
|
|
|
|
while(choix == 0){
|
|
|
|
|
ChoisirCouleurDessin(CouleurParNom("black"));
|
|
|
|
|
DessinerRectangle(100, 100, 200, 50);
|
|
|
|
|
EcrireTexte(120, 135, "Rejouer ?", 2);
|
|
|
|
|
DessinerRectangle(400, 100, 200, 50);
|
|
|
|
|
EcrireTexte(420, 135, "Quitter ?", 2);
|
2024-11-20 14:10:43 +01:00
|
|
|
if(SourisCliquee()){
|
|
|
|
|
SourisX = _X;
|
|
|
|
|
SourisY = _Y;
|
|
|
|
|
}
|
|
|
|
|
if(SourisX <= 300 && SourisX >= 100 && SourisY <= 150 && SourisY >= 100){
|
|
|
|
|
choix++;
|
|
|
|
|
}else if(SourisX <= 600 && SourisX >= 400 && SourisY <= 150 && SourisY >= 100){
|
|
|
|
|
choix = 5;
|
|
|
|
|
}
|
2024-11-18 17:18:12 +01:00
|
|
|
if(victoire == 1){
|
2024-11-20 15:01:35 +01:00
|
|
|
EcrireTexte(200, 235, "Joueur 1 a gagner !", 2);
|
2024-11-18 17:18:12 +01:00
|
|
|
}else if (victoire == 2){
|
2024-11-20 15:01:35 +01:00
|
|
|
EcrireTexte(200, 235, "Joueur 2 a gagner !", 2);
|
2024-11-20 14:10:43 +01:00
|
|
|
}else if (victoire == 3){
|
2024-11-20 15:01:35 +01:00
|
|
|
EcrireTexte(200, 235, "L'IA a gagner !", 2);
|
2024-11-18 17:18:12 +01:00
|
|
|
}
|
|
|
|
|
if(choix == 5){
|
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-10-25 13:08:43 +02:00
|
|
|
}
|
2024-11-20 15:01:35 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
int Jeu(){
|
|
|
|
|
int choix[2], taille = 0, victoire = 0;
|
|
|
|
|
Menu(choix);
|
|
|
|
|
taille = choix[1];
|
|
|
|
|
if(choix[0] == 1){
|
|
|
|
|
victoire = compJCJ(taille);
|
|
|
|
|
}else if (choix[0] == 2){
|
|
|
|
|
compJCIA(taille);
|
|
|
|
|
}
|
|
|
|
|
return victoire;
|
|
|
|
|
}
|