initialisation
This commit is contained in:
		
							
								
								
									
										6
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								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 | ||||
|  | ||||
|   | ||||
| @@ -2,9 +2,17 @@ | ||||
|  | ||||
| #include <stdio.h> | ||||
|  | ||||
|  | ||||
| #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){ | ||||
|   | ||||
							
								
								
									
										36
									
								
								definirMaxXY.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								definirMaxXY.c
									
									
									
									
									
										Normal file
									
								
							| @@ -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; | ||||
| } | ||||
							
								
								
									
										9
									
								
								definirMaxXY.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								definirMaxXY.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | ||||
| #ifndef DEFINIRMAXXY_H | ||||
| #define DEFINIRMAXXY_H | ||||
|  | ||||
|  | ||||
| int DefMaxX(int taille); | ||||
| int DefMaxY(int taille); | ||||
|  | ||||
|  | ||||
| #endif | ||||
							
								
								
									
										5
									
								
								initialisation.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								initialisation.c
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,5 @@ | ||||
|  | ||||
|  | ||||
|  | ||||
| int initialisation(int SourisX, int SourisY, int maxX, int maxY){ | ||||
| } | ||||
							
								
								
									
										7
									
								
								initialisation.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								initialisation.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,7 @@ | ||||
| #ifndef INITIALISATION_H | ||||
| #define INITIALISATION_H | ||||
|  | ||||
| int initialisation(int SourisX, int SourisY, int maxX, int maxY); | ||||
|  | ||||
|  | ||||
| #endif | ||||
		Reference in New Issue
	
	Block a user