From f2880c2bbf039e50fcb776ba0d013208d99394c5 Mon Sep 17 00:00:00 2001 From: abraham Date: Fri, 15 Nov 2024 09:50:42 +0100 Subject: [PATCH] initialisation --- Makefile | 6 +++++- comportementJCJ.c | 24 ++++++++++++++++-------- definirMaxXY.c | 36 ++++++++++++++++++++++++++++++++++++ definirMaxXY.h | 9 +++++++++ initialisation.c | 5 +++++ initialisation.h | 7 +++++++ 6 files changed, 78 insertions(+), 9 deletions(-) create mode 100644 definirMaxXY.c create mode 100644 definirMaxXY.h create mode 100644 initialisation.c create mode 100644 initialisation.h diff --git a/Makefile b/Makefile index a269249..27aaf0e 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,8 @@ OFILES = taille.o \ jeu.o \ comportementJCJ.o \ comportementJCIA.o \ + definirMaxXY.o \ + initialisation.o \ main.o @@ -26,9 +28,11 @@ menu.o : taille.h menu.h nbjoueur.h nbjoueur2.h boutonJVJ.h grille.h taille.o : taille.h jeu.h +initialisation.o : initialisation.h + nbjoueur.o : nbjoueur.h -comportementJCJ.o : comportementJCJ.h +comportementJCJ.o : comportementJCJ.h definirMaxXY.h initialisation.h comportementJCIA.o : comportementJCIA.h diff --git a/comportementJCJ.c b/comportementJCJ.c index ed4d4e9..2fb45eb 100644 --- a/comportementJCJ.c +++ b/comportementJCJ.c @@ -2,9 +2,17 @@ #include + +#include "definirMaxXY.h" +#include "initialisation.h" + + void compJCJ(int taille){ - int fin = 0, tabx = 0, taby = 0, tour = 0, initialisation = 0, SourisX = 0, SourisY = 0, x = 50, y = 100; + int fin = 0, tabx = 0, taby = 0, tour = 0, initi = 0, SourisX = 0, SourisY = 0, x = 50, y = 100, initialiser = 0; + int maxX = 0, maxY = 0; int grille[taille+2][taille+2]; + maxX = DefMaxX(taille); + maxY = DefMaxY(taille); for(tabx = 0; tabx < taille + 2; tabx++){ for(taby = 0; taby < taille + 2; taby++){ grille[tabx][taby] = 0; @@ -16,19 +24,19 @@ void compJCJ(int taille){ printf("\n"); } EcrireTexte(30, 40, "Joueur 1 choisissez l'emplacement de base du pion 1", 1); - while(initialisation == 0){ + while(initi == 0){ if(SourisCliquee()){ SourisX = _X; SourisY = _Y; printf("%d, %d\n", SourisX, SourisY); + printf("max X Y : %d, %d\n", maxX, maxY); } - for(y = 100; y < taille * 75; y += 50){ - for(x = 50; x < taille * 75; x += 50){ - if(SourisX >= x && SourisY >= y && SourisX <= x + 50 && SourisY <= y + 50){ - printf("test\n"); - DessinerSegment(0, 0, 500, 500); - } + if(initialiser == 0){ + if(SourisX >= 200 && SourisX <= maxX && SourisY >= 250 && SourisY <= maxY){ + printf("entre max\n"); + initialisation(SourisX, SourisY, maxX, maxY); } + }else if (initialiser == 1){ } } while(fin == 0){ diff --git a/definirMaxXY.c b/definirMaxXY.c new file mode 100644 index 0000000..eb5980c --- /dev/null +++ b/definirMaxXY.c @@ -0,0 +1,36 @@ + + +/* + * 3 : x = 200 y = 250 + * 4 : x = 250 y = 300 + * 5 : x = 300 y = 350 + * 6 : x = 350 y = 400 + * 7 : x = 400 y = 450 + * 8 : x = 450 y = 500 + * 9 : x = 500 y = 550 + */ + +int DefMaxX(int taille){ + int maxX = 0, x = 0, max = 200; + if(taille == 3){ + maxX = 200; + } + for(x = 3; x < 10; x++){ + if(taille == x){ + maxX = max; + } + max += 50; + } + return maxX; +} + +int DefMaxY(int taille){ + int maxY = 0, x = 0, max = 250; + for(x = 3; x < 10; x++){ + if(taille == x){ + maxY = max; + } + max += 50; + } + return maxY; +} diff --git a/definirMaxXY.h b/definirMaxXY.h new file mode 100644 index 0000000..a5dc1b0 --- /dev/null +++ b/definirMaxXY.h @@ -0,0 +1,9 @@ +#ifndef DEFINIRMAXXY_H +#define DEFINIRMAXXY_H + + +int DefMaxX(int taille); +int DefMaxY(int taille); + + +#endif diff --git a/initialisation.c b/initialisation.c new file mode 100644 index 0000000..0dde763 --- /dev/null +++ b/initialisation.c @@ -0,0 +1,5 @@ + + + +int initialisation(int SourisX, int SourisY, int maxX, int maxY){ +} diff --git a/initialisation.h b/initialisation.h new file mode 100644 index 0000000..06a69e4 --- /dev/null +++ b/initialisation.h @@ -0,0 +1,7 @@ +#ifndef INITIALISATION_H +#define INITIALISATION_H + +int initialisation(int SourisX, int SourisY, int maxX, int maxY); + + +#endif