netoyage de fichier

This commit is contained in:
2024-11-20 15:01:35 +01:00
parent 685a4ce478
commit 5e9d6560b7
24 changed files with 114 additions and 198 deletions

View File

@@ -7,16 +7,11 @@ but : game
OFILES = taille.o \
menu.o \
nbjoueur.o \
nbjoueur2.o \
boutonJVJ.o \
jeu.o \
comportementJCJ.o \
comportementJCIA.o \
definirMaxXY.o \
initialisation.o \
coordoner.o \
effacehaut.o \
verificationblock.o \
main.o
@@ -26,31 +21,21 @@ CFLAGS = -Wall -ansi -pedantic
# CHAPITRE 3 : DEPENDANCES (REGLES IMPLICITES)
menu.o : taille.h menu.h nbjoueur.h nbjoueur2.h boutonJVJ.h
menu.o : taille.h menu.h nbjoueur.h
taille.o : taille.h jeu.h
taille.o : taille.h
effacehaut.o : effacehaut.h
coordoner.o : coordoner.h
verificationblock.o : verificationblock.h
coordoner.o : coordoner.h initialisation.h
initialisation.o : initialisation.h
nbjoueur.o : nbjoueur.h
comportementJCJ.o : comportementJCJ.h definirMaxXY.h initialisation.h coordoner.h effacehaut.h verificationblock.h
comportementJCJ.o : comportementJCJ.h definirMaxXY.h initialisation.h coordoner.h
comportementJCIA.o : comportementJCIA.h
comportementJCIA.o : comportementJCIA.h definirMaxXY.h initialisation.h coordoner.h
boutonJVJ.o : boutonJVJ.h
nbjoueur2.o : nbjoueur2.h
jeu.o : jeu.h menu.h comportementJCJ.h comportementJCIA.h
main.o : jeu.h
main.o : menu.h comportementJCJ.h comportementJCIA.h
# CHAPITRE 4 : DEPENDANCES AVEC COMMANDES

View File

@@ -1,19 +0,0 @@
#include <graph.h>
/* Fonction qui permet de délimiter le clique de la souris pour le bouton de Joueur contre Joueur */
int boutonJVJ(){
int choix = 0, SourisX = 0, SourisY = 0;
while(choix == 0){ /* Boucle effectif tant que le joueur n'a pas fais de choix */
if (SourisCliquee()){ /* Détecte quand le joueur clique et met les coordonées du clique de SourisX et Souris Y */
SourisX = _X;
SourisY = _Y;
}
if(SourisX > 100 && SourisX < 250 && SourisY > 150 && SourisY < 200){
choix = 1; /* Quand le joueur clique dans l'emplacement de Joueur contre Joueur choix = 1 */
}else if(SourisX > 400 && SourisX < 550 && SourisY > 150 && SourisY < 200){
choix = 2; /* Quand le joueur cliqye dans l'emplacement de Joueur contre IA choix = 2 */
}
}
return choix; /* On retourne choix pour que le menu puisse le retourner a jeu.c pour faire la selection de l'ennemie */
}

View File

@@ -1,7 +0,0 @@
#ifndef BOUTONJVJ_H
#define BOUTONJVIA_H
int boutonJVJ();
#endif

View File

@@ -4,8 +4,6 @@
#include "definirMaxXY.h"
#include "initialisation.h"
#include "coordoner.h"
#include "effacehaut.h"
#include "verificationblock.h"
int compJCIA(int taille){
@@ -14,6 +12,7 @@ int compJCIA(int taille){
int emplacementcooX1 = 0, emplacementcooX2 = 0, emplacementcooY1 = 0, emplacementcooY2 = 0;
int grille[taille+2][taille+2];
int empblock[4] = {0, 0, 0, 0}, empperso[4] = {0, 0, 0, 0};
srand(time(NULL));
maxX = DefMaxX(taille);
maxY = DefMaxY(taille);
for(tabx = 0; tabx < taille + 2; tabx++){
@@ -42,7 +41,7 @@ int compJCIA(int taille){
initialiser++;
SourisX = 0;
SourisY = 0;
Efface();
EffaceIA();
EcrireTexte(30, 40, "Joueur 2 choisissez l'emplacement de base du pion 2", 1);
}
}else if (initialiser == 1){
@@ -69,7 +68,7 @@ int compJCIA(int taille){
ChargerSprite("croix2.png");
while(fin == 0){
if(tour == 0){
Efface();
EffaceIA();
EcrireTexte(30, 40, "Tour du joueur 1", 2);
SourisX = 0;
SourisY = 0;
@@ -108,7 +107,7 @@ int compJCIA(int taille){
placer = 1;
tour++;
}else if(tour == 1){
Efface();
EffaceIA();
EcrireTexte(30, 40, "Joueur 1 place le bloc", 2);
SourisX = 0;
SourisY = 0;
@@ -132,7 +131,7 @@ int compJCIA(int taille){
placer = 1;
tour++;
}else if(tour == 2){
Efface();
EffaceIA();
EcrireTexte(30, 40, "Tour du joueur 2", 2);
SourisX = 0;
SourisY = 0;
@@ -170,7 +169,7 @@ int compJCIA(int taille){
tour++;
}else if(tour == 3){
Efface();
EffaceIA();
EcrireTexte(30, 40, "Joueur 2 place le bloc", 2);
SourisX = 0;
SourisY = 0;
@@ -194,3 +193,10 @@ int compJCIA(int taille){
}
}
}
void EffaceIA(){
ChoisirCouleurDessin(CouleurParNom("white"));
RemplirRectangle(0, 0, 650, 50);
ChoisirCouleurDessin(CouleurParNom("black"));
}

View File

@@ -4,5 +4,6 @@
void compJCIA(int taille);
void EffaceIA();
#endif

View File

@@ -4,8 +4,6 @@
#include "definirMaxXY.h"
#include "initialisation.h"
#include "coordoner.h"
#include "effacehaut.h"
#include "verificationblock.h"
int compJCJ(int taille){
@@ -195,4 +193,11 @@ int compJCJ(int taille){
tour = 0;
}
}
return 0;
}
void Efface(){
ChoisirCouleurDessin(CouleurParNom("white"));
RemplirRectangle(0, 0, 650, 50);
ChoisirCouleurDessin(CouleurParNom("black"));
}

View File

@@ -4,5 +4,6 @@
int compJCJ(int taille);
void Efface();
#endif

View File

@@ -1,3 +1,5 @@
#include "initialisation.h"
int coordonerX(int SourisX){
int x = 0, z = 0;
for(z = 50; z <= 500; z += 50){
@@ -18,3 +20,15 @@ int coordonerY(int SourisY){
}
return x;
}
void VerifBlock1(int SourisX, int SourisY, int maxX, int maxY, int taille, int* coordoner){
int placementX = 0, placementY = 0;
if(SourisX >= 50 && SourisX <= maxX && SourisY >= 100 && SourisY <= maxY){
placementX = initialisationXbox(SourisX, maxX, taille);
placementY = initialisationYbox(SourisY, maxY, taille);
}
coordoner[0] = placementX;
coordoner[1] = placementY;
}

View File

@@ -6,4 +6,6 @@ int coordonerX(int SourisX);
int coordonerY(int SourisY);
void VerifBlock1(int SourisX, int SourisY, int maxX, int maxY, int taille, int* coordoner);
#endif

View File

@@ -1,8 +0,0 @@
#include <graph.h>
void Efface(void){
ChoisirCouleurDessin(CouleurParNom("white"));
RemplirRectangle(0, 0, 650, 50);
ChoisirCouleurDessin(CouleurParNom("black"));
}

View File

@@ -1,7 +0,0 @@
#ifndef EFFACEHAUT_H
#define EFFACEHAUT_H
void Efface();
#endif

View File

@@ -1,27 +0,0 @@
#include <graph.h>
void Grille(int taille){
int bord = 0, x = 100, xx = 50, y = 100, yy = 100;
ChoisirCouleurDessin(CouleurParNom("Black"));
for(bord = 0; bord < taille; bord++){
DessinerSegment(50, 100, x, 100); /* Dessine le bord du haut de la grille */
x += 50;
}
x -= 50; /* Enlève le surplus de la fonction for */
for(bord = 0; bord <= taille; bord++){
DessinerSegment(50, 100, 50 , y); /* Dessine les barre latérale en fonction de la taille choisie */
DessinerSegment(x, 100, x, y);
y += 50;
}
y -= 50; /* Enlève le surplus de la fonction for */
DessinerSegment(50, y, x, y);
for(bord = 0; bord <= taille; bord++){
DessinerSegment(50, yy, x, yy); /* Dessine les barre horizontale de l'intérieur de la grille */
yy += 50;
}
for(bord = 0; bord <= taille; bord++){
DessinerSegment(xx, 100, xx, y); /* Dessine les barre verticale de l'intérieur de la grille */
xx += 50;
}
}

26
jeu.c
View File

@@ -1,26 +0,0 @@
#include <graph.h>
#include "menu.h"
#include "comportementJCJ.h"
#include "comportementJCIA.h"
int Jeu(){
int choix[2], taille = 0, victoire = 0;
Menu(choix);
taille = choix[1];
if(choix[0] == 1){
victoire = compJCJ(taille);
if(victoire == 1){
return 1;
}else if(victoire == 2){
return 2;
}
}else if (choix[0] == 2){
compJCIA(taille);
if(victoire == 1){
return 1;
}else if(victoire == 3){
return 3;
}
}
}

8
jeu.h
View File

@@ -1,8 +0,0 @@
#ifndef JEU_H
#define JEU_H
int Jeu();
#endif

24
main.c
View File

@@ -1,7 +1,10 @@
#include <graph.h>
#include <stdlib.h>
#include "jeu.h"
#include "menu.h"
#include "comportementJCJ.h"
#include "comportementJCIA.h"
int main (void){
int victoire = 0, choix = 0, SourisX = 0, SourisY = 0;
@@ -32,11 +35,11 @@ int main (void){
choix = 5;
}
if(victoire == 1){
EcrireTexte(300, 235, "Joueur 1 a gagner !", 2);
EcrireTexte(200, 235, "Joueur 1 a gagner !", 2);
}else if (victoire == 2){
EcrireTexte(300, 235, "Joueur 2 a gagner !", 2);
EcrireTexte(200, 235, "Joueur 2 a gagner !", 2);
}else if (victoire == 3){
EcrireTexte(300, 235, "L'IA a gagner !", 2);
EcrireTexte(200, 235, "L'IA a gagner !", 2);
}
if(choix == 5){
return EXIT_SUCCESS;
@@ -44,3 +47,16 @@ int main (void){
}
}
}
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;
}

24
menu.c
View File

@@ -2,11 +2,9 @@
#include "taille.h"
#include "nbjoueur.h"
#include "nbjoueur2.h"
#include "boutonJVJ.h"
int Menu(int *retour) {
void Menu(int *retour) {
int x = 50, y = 50, taille = -5, choix = 0, echotaille = 0, verrou = 0; /* initialisation des variable */
couleur c = CouleurParNom("white");
while(choix == 0){ /* Condition pour que le menu s'arrête quand le joueur aura selectionner le nombre de joueur */
@@ -66,3 +64,23 @@ void Grille(int taille){
}
}
/* Fonction qui permet de délimiter le clique de la souris pour le bouton de Joueur contre Joueur */
int boutonJVJ(){
int choix = 0, SourisX = 0, SourisY = 0;
while(choix == 0){ /* Boucle effectif tant que le joueur n'a pas fais de choix */
if (SourisCliquee()){ /* Détecte quand le joueur clique et met les coordonées du clique de SourisX et Souris Y */
SourisX = _X;
SourisY = _Y;
}
if(SourisX > 100 && SourisX < 250 && SourisY > 150 && SourisY < 200){
choix = 1; /* Quand le joueur clique dans l'emplacement de Joueur contre Joueur choix = 1 */
}else if(SourisX > 400 && SourisX < 550 && SourisY > 150 && SourisY < 200){
choix = 2; /* Quand le joueur cliqye dans l'emplacement de Joueur contre IA choix = 2 */
}
}
return choix; /* On retourne choix pour que le menu puisse le retourner a jeu.c pour faire la selection de l'ennemie */
}

4
menu.h
View File

@@ -2,8 +2,10 @@
#define MENU_H
int Menu(int *retour);
void Menu(int *retour);
void Grille(int taille);
int boutonJCJ();
#endif

View File

@@ -7,7 +7,7 @@
int nbjoueur(){
void nbjoueur(){
int x = 100, xx = 250, y = 150, l = 30, h = 30, angle1 = 20, angle2 = 30;
ChoisirCouleurDessin(CouleurParNom("Black"));
DessinerSegment(x, y, xx, y);
@@ -20,3 +20,24 @@ int nbjoueur(){
DessinerSegment(x - 8, y + 9, x - 8, y + 43);
DessinerSegment(xx + 6, y + 8, xx + 6, y + 43);
}
/*
* Fonction qui permet de déssiner le bouton du joueur contre IA
*/
void nbjoueur2(){
int x = 400, xx = 550, y = 150, l = 30, h = 30, angle1 = 20, angle2 = 30;
ChoisirCouleurDessin(CouleurParNom("Black"));
DessinerSegment(x, y, xx, y);
DessinerSegment(x - 2, y + 50, xx, y + 50);
EcrireTexte(x + 10, y + 35, "J1 VS IA", 2);
DessinerArc(xx - 23, y - 3, l, h, angle1, angle2);
DessinerArc(x - 9, y - 2, l, h, angle1 + 100, angle2 + 10);
DessinerArc(xx - 23, y + 23, l, h, angle1 + 290, angle2);
DessinerArc(x - 9, y + 23, l, h, angle1 + 180, angle2);
DessinerSegment(x - 8, y + 9, x - 8, y + 43);
DessinerSegment(xx + 6, y + 8, xx + 6, y + 43);
}

View File

@@ -2,7 +2,8 @@
#define NBJOUEUR_H
int nbjoueur();
void nbjoueur();
void nbjoueur2();
#endif

View File

@@ -1,23 +0,0 @@
#include <graph.h>
/*
* Fonction qui permet de déssiner le bouton du joueur contre IA
*/
int nbjoueur2(){
int x = 400, xx = 550, y = 150, l = 30, h = 30, angle1 = 20, angle2 = 30;
ChoisirCouleurDessin(CouleurParNom("Black"));
DessinerSegment(x, y, xx, y);
DessinerSegment(x - 2, y + 50, xx, y + 50);
EcrireTexte(x + 10, y + 35, "J1 VS IA", 2);
DessinerArc(xx - 23, y - 3, l, h, angle1, angle2);
DessinerArc(x - 9, y - 2, l, h, angle1 + 100, angle2 + 10);
DessinerArc(xx - 23, y + 23, l, h, angle1 + 290, angle2);
DessinerArc(x - 9, y + 23, l, h, angle1 + 180, angle2);
DessinerSegment(x - 8, y + 9, x - 8, y + 43);
DessinerSegment(xx + 6, y + 8, xx + 6, y + 43);
}

View File

@@ -1,8 +0,0 @@
#ifndef NBJOUEUR2_H
#define NBJOUEUR2_H
int nbjoueur2();
#endif

View File

@@ -82,7 +82,5 @@ int GererChoixTaille(){
taille = 9;
}
}
if(taille != 0){
return taille;
}
}
return taille;
}

View File

@@ -1,14 +0,0 @@
#include <graph.h>
#include "initialisation.h"
int VerifBlock1(int SourisX, int SourisY, int maxX, int maxY, int taille, int* coordoner){
int placementX = 0, placementY = 0;
if(SourisX >= 50 && SourisX <= maxX && SourisY >= 100 && SourisY <= maxY){
placementX = initialisationXbox(SourisX, maxX, taille);
placementY = initialisationYbox(SourisY, maxY, taille);
}
coordoner[0] = placementX;
coordoner[1] = placementY;
}

View File

@@ -1,7 +0,0 @@
#ifndef VERIFICATIONBLOCK_H
#define VERIFICATIONBLOCK_H
int VerifBlock1(int SourisX, int SourisY, int maxX, int maxY, int taille, int* coordoner);
#endif