Compare commits
2 Commits
78bdfbd44a
...
685a4ce478
| Author | SHA1 | Date | |
|---|---|---|---|
| 685a4ce478 | |||
| e650605ead |
7
Makefile
7
Makefile
@@ -6,7 +6,6 @@ but : game
|
|||||||
|
|
||||||
OFILES = taille.o \
|
OFILES = taille.o \
|
||||||
menu.o \
|
menu.o \
|
||||||
grille.o \
|
|
||||||
nbjoueur.o \
|
nbjoueur.o \
|
||||||
nbjoueur2.o \
|
nbjoueur2.o \
|
||||||
boutonJVJ.o \
|
boutonJVJ.o \
|
||||||
@@ -27,7 +26,7 @@ CFLAGS = -Wall -ansi -pedantic
|
|||||||
|
|
||||||
# CHAPITRE 3 : DEPENDANCES (REGLES IMPLICITES)
|
# CHAPITRE 3 : DEPENDANCES (REGLES IMPLICITES)
|
||||||
|
|
||||||
menu.o : taille.h menu.h nbjoueur.h nbjoueur2.h boutonJVJ.h grille.h
|
menu.o : taille.h menu.h nbjoueur.h nbjoueur2.h boutonJVJ.h
|
||||||
|
|
||||||
taille.o : taille.h jeu.h
|
taille.o : taille.h jeu.h
|
||||||
|
|
||||||
@@ -43,14 +42,12 @@ 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 effacehaut.h verificationblock.h
|
||||||
|
|
||||||
comportementJCIA.o : comportementJCIA.h definirMaxXY.h initialisation.h coordoner.h effacehaut.h verificationblock.h
|
comportementJCIA.o : comportementJCIA.h
|
||||||
|
|
||||||
boutonJVJ.o : boutonJVJ.h
|
boutonJVJ.o : boutonJVJ.h
|
||||||
|
|
||||||
nbjoueur2.o : nbjoueur2.h
|
nbjoueur2.o : nbjoueur2.h
|
||||||
|
|
||||||
grille.o : grille.h
|
|
||||||
|
|
||||||
jeu.o : jeu.h menu.h comportementJCJ.h comportementJCIA.h
|
jeu.o : jeu.h menu.h comportementJCJ.h comportementJCIA.h
|
||||||
|
|
||||||
main.o : jeu.h
|
main.o : jeu.h
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
#include <graph.h>
|
#include <graph.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
|
|
||||||
#include "definirMaxXY.h"
|
#include "definirMaxXY.h"
|
||||||
#include "initialisation.h"
|
#include "initialisation.h"
|
||||||
@@ -11,7 +9,7 @@
|
|||||||
|
|
||||||
|
|
||||||
int compJCIA(int taille){
|
int compJCIA(int taille){
|
||||||
int fin = 0, tabx = 0, taby = 0, tour = 0, initi = 0, SourisX = 0, SourisY = 0, initialiser = 0, inialea = 0;
|
int fin = 0, tabx = 0, taby = 0, tour = 0, initi = 0, SourisX = 0, SourisY = 0, initialiser = 0;
|
||||||
int maxX = 0, maxY = 0, joueurx1 = 0, joueury1 = 0, joueurx2 = 0, joueury2 = 0, placer = 1;
|
int maxX = 0, maxY = 0, joueurx1 = 0, joueury1 = 0, joueurx2 = 0, joueury2 = 0, placer = 1;
|
||||||
int emplacementcooX1 = 0, emplacementcooX2 = 0, emplacementcooY1 = 0, emplacementcooY2 = 0;
|
int emplacementcooX1 = 0, emplacementcooX2 = 0, emplacementcooY1 = 0, emplacementcooY2 = 0;
|
||||||
int grille[taille+2][taille+2];
|
int grille[taille+2][taille+2];
|
||||||
@@ -41,27 +39,32 @@ int compJCIA(int taille){
|
|||||||
emplacementcooY1 = coordonerY(SourisY);
|
emplacementcooY1 = coordonerY(SourisY);
|
||||||
AfficherSprite(1, emplacementcooX1, emplacementcooY1);
|
AfficherSprite(1, emplacementcooX1, emplacementcooY1);
|
||||||
grille[joueury1][joueurx1] = 1;
|
grille[joueury1][joueurx1] = 1;
|
||||||
initialiser = 0;
|
initialiser++;
|
||||||
initi++;
|
SourisX = 0;
|
||||||
|
SourisY = 0;
|
||||||
|
Efface();
|
||||||
|
EcrireTexte(30, 40, "Joueur 2 choisissez l'emplacement de base du pion 2", 1);
|
||||||
|
}
|
||||||
|
}else if (initialiser == 1){
|
||||||
|
SourisX = rand() % maxX;
|
||||||
|
SourisY = rand() % maxY;
|
||||||
|
if(SourisX >= 50 && SourisX <= maxX && SourisY >= 100 && SourisY <= maxY){
|
||||||
|
ChargerSprite("pion2.png");
|
||||||
|
joueurx2 = initialisationX(SourisX, maxX, taille);
|
||||||
|
joueury2 = initialisationY(SourisY, maxY, taille);
|
||||||
|
if(grille[joueury2][joueurx2] != 1){
|
||||||
|
emplacementcooX2 = coordonerX(SourisX);
|
||||||
|
emplacementcooY2 = coordonerY(SourisY);
|
||||||
|
AfficherSprite(2, emplacementcooX2, emplacementcooY2);
|
||||||
|
grille[joueury2][joueurx2] = 2;
|
||||||
|
initialiser++;
|
||||||
|
initi++;
|
||||||
|
}
|
||||||
SourisX = 0;
|
SourisX = 0;
|
||||||
SourisY = 0;
|
SourisY = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
initialiser = 1;
|
|
||||||
ChargerSprite("pion2.png");
|
|
||||||
while(initialiser == 1){
|
|
||||||
emplacementcooX2 = rand() % maxX + 95;
|
|
||||||
emplacementcooY2 = rand() % maxY - 12;
|
|
||||||
joueurx2 = initialisationX(emplacementcooX2, maxX, taille);
|
|
||||||
joueury2 = initialisationY(emplacementcooY2, maxY, taille);
|
|
||||||
printf("%d, %d\n", joueurx2, joueury2);
|
|
||||||
if(grille[joueury2][joueurx2] == 0){
|
|
||||||
AfficherSprite(2, emplacementcooX2, emplacementcooY2);
|
|
||||||
grille[joueury2][joueurx2] = 2;
|
|
||||||
initialiser++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ChargerSprite("croix1.png");
|
ChargerSprite("croix1.png");
|
||||||
ChargerSprite("croix2.png");
|
ChargerSprite("croix2.png");
|
||||||
while(fin == 0){
|
while(fin == 0){
|
||||||
@@ -81,7 +84,7 @@ int compJCIA(int taille){
|
|||||||
LibererSprite(2);
|
LibererSprite(2);
|
||||||
LibererSprite(3);
|
LibererSprite(3);
|
||||||
LibererSprite(4);
|
LibererSprite(4);
|
||||||
return 2;
|
return 3;
|
||||||
}
|
}
|
||||||
if(empperso[0] != 0){
|
if(empperso[0] != 0){
|
||||||
if(grille[empperso[1]][empperso[0]] == 0 && (empperso[1] <= joueury1+1 && empperso[1] >= joueury1-1) && (empperso[0] <= joueurx1+1 && empperso[0] >= joueurx1-1)){
|
if(grille[empperso[1]][empperso[0]] == 0 && (empperso[1] <= joueury1+1 && empperso[1] >= joueury1-1) && (empperso[0] <= joueurx1+1 && empperso[0] >= joueurx1-1)){
|
||||||
@@ -134,10 +137,8 @@ int compJCIA(int taille){
|
|||||||
SourisX = 0;
|
SourisX = 0;
|
||||||
SourisY = 0;
|
SourisY = 0;
|
||||||
while(placer == 1){
|
while(placer == 1){
|
||||||
if(SourisCliquee()){
|
SourisX = rand() % maxX;
|
||||||
SourisX = _X;
|
SourisY = rand() % maxY;
|
||||||
SourisY = _Y;
|
|
||||||
}
|
|
||||||
VerifBlock1(SourisX, SourisY, maxX, maxY, taille, empperso);
|
VerifBlock1(SourisX, SourisY, maxX, maxY, taille, empperso);
|
||||||
if(grille[joueury2+1][joueurx2] != 0 && grille[joueury2-1][joueurx2] != 0 && grille[joueury2+1][joueurx2+1] != 0 && grille[joueury2-1][joueurx2-1] != 0 && grille[joueury2][joueurx2+1] != 0 && grille[joueury2][joueurx2-1] != 0){
|
if(grille[joueury2+1][joueurx2] != 0 && grille[joueury2-1][joueurx2] != 0 && grille[joueury2+1][joueurx2+1] != 0 && grille[joueury2-1][joueurx2-1] != 0 && grille[joueury2][joueurx2+1] != 0 && grille[joueury2][joueurx2-1] != 0){
|
||||||
LibererSprite(1);
|
LibererSprite(1);
|
||||||
@@ -174,10 +175,8 @@ int compJCIA(int taille){
|
|||||||
SourisX = 0;
|
SourisX = 0;
|
||||||
SourisY = 0;
|
SourisY = 0;
|
||||||
while(placer == 1){
|
while(placer == 1){
|
||||||
if(SourisCliquee()){
|
SourisX = rand() % maxX;
|
||||||
SourisX = _X;
|
SourisY = rand() % maxY;
|
||||||
SourisY = _Y;
|
|
||||||
}
|
|
||||||
VerifBlock1(SourisX, SourisY, maxX, maxY, taille, empblock);
|
VerifBlock1(SourisX, SourisY, maxX, maxY, taille, empblock);
|
||||||
if(empblock[0] != 0){
|
if(empblock[0] != 0){
|
||||||
if(grille[empblock[1]][empblock[0]] == 0){
|
if(grille[empblock[1]][empblock[0]] == 0){
|
||||||
@@ -194,5 +193,4 @@ int compJCIA(int taille){
|
|||||||
tour = 0;
|
tour = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#define COMPORTEMENTJCIA_H
|
#define COMPORTEMENTJCIA_H
|
||||||
|
|
||||||
|
|
||||||
int compJCIA(int taille);
|
void compJCIA(int taille);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include <graph.h>
|
#include <graph.h>
|
||||||
|
|
||||||
|
|
||||||
#include "definirMaxXY.h"
|
#include "definirMaxXY.h"
|
||||||
#include "initialisation.h"
|
#include "initialisation.h"
|
||||||
#include "coordoner.h"
|
#include "coordoner.h"
|
||||||
@@ -167,6 +168,7 @@ int compJCJ(int taille){
|
|||||||
empperso[0] = 0;
|
empperso[0] = 0;
|
||||||
placer = 1;
|
placer = 1;
|
||||||
tour++;
|
tour++;
|
||||||
|
|
||||||
}else if(tour == 3){
|
}else if(tour == 3){
|
||||||
Efface();
|
Efface();
|
||||||
EcrireTexte(30, 40, "Joueur 2 place le bloc", 2);
|
EcrireTexte(30, 40, "Joueur 2 place le bloc", 2);
|
||||||
@@ -193,5 +195,4 @@ int compJCJ(int taille){
|
|||||||
tour = 0;
|
tour = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
int coordonerX(int SourisX){
|
int coordonerX(int SourisX){
|
||||||
int x = 0, z = 0; /* Retourne les coordoner précis de X pour l'affichage de l'image */
|
int x = 0, z = 0;
|
||||||
for(z = 50; z <= 500; z += 50){
|
for(z = 50; z <= 500; z += 50){
|
||||||
if(SourisX > z){
|
if(SourisX > z){
|
||||||
x = z + 5;
|
x = z + 5;
|
||||||
@@ -10,7 +10,7 @@ int coordonerX(int SourisX){
|
|||||||
|
|
||||||
|
|
||||||
int coordonerY(int SourisY){
|
int coordonerY(int SourisY){
|
||||||
int x = 0, z = 0; /* Retourn les coordoner précis de Y pour l'affichage de l'image */
|
int x = 0, z = 0;
|
||||||
for(z = 100; z <= 550; z += 50){
|
for(z = 100; z <= 550; z += 50){
|
||||||
if(SourisY > z){
|
if(SourisY > z){
|
||||||
x = z + 5;
|
x = z + 5;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
* 9 : x = 500 y = 550
|
* 9 : x = 500 y = 550
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int DefMaxX(int taille){ /* Retourne les coordonées maximale de X par rapport a la taille du tableau selectionner */
|
int DefMaxX(int taille){
|
||||||
int maxX = 0, x = 0, max = 200;
|
int maxX = 0, x = 0, max = 200;
|
||||||
if(taille == 3){
|
if(taille == 3){
|
||||||
maxX = 200;
|
maxX = 200;
|
||||||
@@ -24,7 +24,7 @@ int DefMaxX(int taille){ /* Retourne les coordonées maximale de X par rapport
|
|||||||
return maxX;
|
return maxX;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DefMaxY(int taille){ /* Retourne les coordonées maximale de Y par rapport a la taille du tableau selectionner */
|
int DefMaxY(int taille){
|
||||||
int maxY = 0, x = 0, max = 250;
|
int maxY = 0, x = 0, max = 250;
|
||||||
for(x = 3; x < 10; x++){
|
for(x = 3; x < 10; x++){
|
||||||
if(taille == x){
|
if(taille == x){
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <graph.h>
|
#include <graph.h>
|
||||||
|
|
||||||
|
|
||||||
void Efface(void){ /* Fonction de feignant qui me permet juste d'effacer le haut de l'affichage de la partie */
|
void Efface(void){
|
||||||
ChoisirCouleurDessin(CouleurParNom("white"));
|
ChoisirCouleurDessin(CouleurParNom("white"));
|
||||||
RemplirRectangle(0, 0, 650, 50);
|
RemplirRectangle(0, 0, 650, 50);
|
||||||
ChoisirCouleurDessin(CouleurParNom("black"));
|
ChoisirCouleurDessin(CouleurParNom("black"));
|
||||||
|
|||||||
9
grille.h
9
grille.h
@@ -1,9 +0,0 @@
|
|||||||
#ifndef GRILLE_H
|
|
||||||
#define GRILLE_H
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Grille(int taille);
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
int initialisationX(int SourisX, int maxX, int taille){ /* Code qui permet de retourner le numéro X de la case ou le joueur veux le pion de base */
|
int initialisationX(int SourisX, int maxX, int taille){
|
||||||
int casejoueur = 0, x = 0, y = 50, verou = 0;
|
int casejoueur = 0, x = 0, y = 50, verou = 0;
|
||||||
for(x = 0; x <= taille; x++){
|
for(x = 0; x <= taille; x++){
|
||||||
if(SourisX >= 50 && SourisX <= maxX){
|
if(SourisX >= 50 && SourisX <= maxX){
|
||||||
@@ -12,7 +12,7 @@ int initialisationX(int SourisX, int maxX, int taille){ /* Code qui permet de
|
|||||||
return casejoueur;
|
return casejoueur;
|
||||||
}
|
}
|
||||||
|
|
||||||
int initialisationY(int SourisY, int maxY, int taille){ /* Code qui permet de retourner le numéro Y de la case ou le joueur veux le pion de base */
|
int initialisationY(int SourisY, int maxY, int taille){
|
||||||
int casejoueur = 0, x = 0, y = 100, verou = 0;
|
int casejoueur = 0, x = 0, y = 100, verou = 0;
|
||||||
for(x = 0; x <= taille; x++){
|
for(x = 0; x <= taille; x++){
|
||||||
if(SourisY >= 100 && SourisY <= maxY){
|
if(SourisY >= 100 && SourisY <= maxY){
|
||||||
@@ -28,7 +28,7 @@ int initialisationY(int SourisY, int maxY, int taille){ /* Code qui permet de
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int initialisationXbox(int SourisX, int maxX, int taille){ /* Retourne X de la case du bloc que l'on veux placer */
|
int initialisationXbox(int SourisX, int maxX, int taille){
|
||||||
int caseblock = 0, x = 0, y = 50, verou = 0;
|
int caseblock = 0, x = 0, y = 50, verou = 0;
|
||||||
for(x = 0; x <= taille; x++){
|
for(x = 0; x <= taille; x++){
|
||||||
if(SourisX >= 50 && SourisX <= maxX){
|
if(SourisX >= 50 && SourisX <= maxX){
|
||||||
@@ -43,7 +43,7 @@ int initialisationXbox(int SourisX, int maxX, int taille){ /* Retourne X de la
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int initialisationYbox(int SourisY, int maxY, int taille){ /* Retourne Y de la case du bloc que l'on veux placer */
|
int initialisationYbox(int SourisY, int maxY, int taille){
|
||||||
int caseblock = 0, x = 0, y = 100, verou = 0;
|
int caseblock = 0, x = 0, y = 100, verou = 0;
|
||||||
for(x = 0; x <= taille; x++){
|
for(x = 0; x <= taille; x++){
|
||||||
if(SourisY >= 100 && SourisY <= maxY){
|
if(SourisY >= 100 && SourisY <= maxY){
|
||||||
|
|||||||
15
jeu.c
15
jeu.c
@@ -6,22 +6,21 @@
|
|||||||
|
|
||||||
int Jeu(){
|
int Jeu(){
|
||||||
int choix[2], taille = 0, victoire = 0;
|
int choix[2], taille = 0, victoire = 0;
|
||||||
Menu(choix); /* Affiche le menu */
|
Menu(choix);
|
||||||
taille = choix[1];
|
taille = choix[1];
|
||||||
if(choix[0] == 1){ /* Si l'utilisateur choisie Player VS Player */
|
if(choix[0] == 1){
|
||||||
victoire = compJCJ(taille);
|
victoire = compJCJ(taille);
|
||||||
if(victoire == 1){ /* Si le joueur 1 a gagner alors retourner 1 */
|
if(victoire == 1){
|
||||||
return 1;
|
return 1;
|
||||||
}else if(victoire == 2){
|
}else if(victoire == 2){
|
||||||
return 2; /* Si le joueur 2 a gagner alors retourner 2 */
|
return 2;
|
||||||
}
|
}
|
||||||
}else if (choix[0] == 2){ /* Si l'utilisateur choisie Player VS IA */
|
}else if (choix[0] == 2){
|
||||||
compJCIA(taille);
|
compJCIA(taille);
|
||||||
if(victoire == 1){
|
if(victoire == 1){
|
||||||
return 1; /* Si le joueur 1 a gagner alors retourner 1 */
|
return 1;
|
||||||
}else if(victoire == 3){
|
}else if(victoire == 3){
|
||||||
return 3; /* Si l'IA a gagner alors retourner 3 */
|
return 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|||||||
30
main.c
30
main.c
@@ -8,35 +8,37 @@ int main (void){
|
|||||||
InitialiserGraphique();
|
InitialiserGraphique();
|
||||||
CreerFenetre(50, 50, 700, 500); /* Initialise la fenetre puis lance le programme jeu.c qui lancera d'autre programme */
|
CreerFenetre(50, 50, 700, 500); /* Initialise la fenetre puis lance le programme jeu.c qui lancera d'autre programme */
|
||||||
while(1){
|
while(1){
|
||||||
|
choix = 0;
|
||||||
SourisX = 0;
|
SourisX = 0;
|
||||||
SourisY = 0;
|
SourisY = 0;
|
||||||
choix = 0;
|
|
||||||
victoire = 0;
|
|
||||||
EffacerEcran(CouleurParNom("white"));
|
EffacerEcran(CouleurParNom("white"));
|
||||||
victoire = Jeu(); /* Récupération du numéro du vainceur */
|
victoire = Jeu();
|
||||||
FermerGraphique();
|
FermerGraphique();
|
||||||
InitialiserGraphique();
|
InitialiserGraphique();
|
||||||
CreerFenetre(50, 50, 700, 500);
|
CreerFenetre(50, 50, 700, 500);
|
||||||
while(choix == 0){ /* Création de la fenetre qui permet de rejouer ou de quitter */
|
while(choix == 0){
|
||||||
ChoisirCouleurDessin(CouleurParNom("black"));
|
ChoisirCouleurDessin(CouleurParNom("black"));
|
||||||
DessinerRectangle(100, 100, 200, 50);
|
DessinerRectangle(100, 100, 200, 50);
|
||||||
EcrireTexte(120, 135, "Rejouer ?", 2);
|
EcrireTexte(120, 135, "Rejouer ?", 2);
|
||||||
DessinerRectangle(400, 100, 200, 50);
|
DessinerRectangle(400, 100, 200, 50);
|
||||||
EcrireTexte(420, 135, "Quitter ?", 2);
|
EcrireTexte(420, 135, "Quitter ?", 2);
|
||||||
while(SourisCliquee()){
|
if(SourisCliquee()){
|
||||||
SourisX = _X;
|
SourisX = _X;
|
||||||
SourisY = _Y;
|
SourisY = _Y;
|
||||||
}
|
}
|
||||||
if(victoire == 1){
|
if(SourisX <= 300 && SourisX >= 100 && SourisY <= 150 && SourisY >= 100){
|
||||||
EcrireTexte(200, 235, "Joueur 1 a gagner !", 2);
|
|
||||||
}else if (victoire == 2){
|
|
||||||
EcrireTexte(200, 235, "Joueur 2 a gagner !", 2);
|
|
||||||
}else if (victoire == 3){
|
|
||||||
EcrireTexte(200, 235, "L'IA a gagner !", 2);
|
|
||||||
} /* Bouton pour quitter ou rejouer */
|
|
||||||
if(SourisX > 100 && SourisX < 300 && SourisY < 150 && SourisY > 100){
|
|
||||||
choix++;
|
choix++;
|
||||||
}else if (SourisX > 400 && SourisX < 600 && SourisY < 150 && SourisY > 100){
|
}else if(SourisX <= 600 && SourisX >= 400 && SourisY <= 150 && SourisY >= 100){
|
||||||
|
choix = 5;
|
||||||
|
}
|
||||||
|
if(victoire == 1){
|
||||||
|
EcrireTexte(300, 235, "Joueur 1 a gagner !", 2);
|
||||||
|
}else if (victoire == 2){
|
||||||
|
EcrireTexte(300, 235, "Joueur 2 a gagner !", 2);
|
||||||
|
}else if (victoire == 3){
|
||||||
|
EcrireTexte(300, 235, "L'IA a gagner !", 2);
|
||||||
|
}
|
||||||
|
if(choix == 5){
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
31
menu.c
31
menu.c
@@ -4,10 +4,9 @@
|
|||||||
#include "nbjoueur.h"
|
#include "nbjoueur.h"
|
||||||
#include "nbjoueur2.h"
|
#include "nbjoueur2.h"
|
||||||
#include "boutonJVJ.h"
|
#include "boutonJVJ.h"
|
||||||
#include "grille.h"
|
|
||||||
|
|
||||||
|
|
||||||
void Menu(int *retour) {
|
int Menu(int *retour) {
|
||||||
int x = 50, y = 50, taille = -5, choix = 0, echotaille = 0, verrou = 0; /* initialisation des variable */
|
int x = 50, y = 50, taille = -5, choix = 0, echotaille = 0, verrou = 0; /* initialisation des variable */
|
||||||
couleur c = CouleurParNom("white");
|
couleur c = CouleurParNom("white");
|
||||||
while(choix == 0){ /* Condition pour que le menu s'arrête quand le joueur aura selectionner le nombre de joueur */
|
while(choix == 0){ /* Condition pour que le menu s'arrête quand le joueur aura selectionner le nombre de joueur */
|
||||||
@@ -39,3 +38,31 @@ void Menu(int *retour) {
|
|||||||
retour[0] = choix;
|
retour[0] = choix;
|
||||||
retour[1] = echotaille;
|
retour[1] = echotaille;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
4
menu.h
4
menu.h
@@ -2,8 +2,8 @@
|
|||||||
#define MENU_H
|
#define MENU_H
|
||||||
|
|
||||||
|
|
||||||
|
int Menu(int *retour);
|
||||||
|
|
||||||
|
void Grille(int taille);
|
||||||
void Menu(int *retour);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
#include <graph.h>
|
#include <graph.h>
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Fonction qui permet de déssiner le bouton du Joueur contre Joueur
|
* Fonction qui permet de déssiner le bouton du Joueur contre Joueur
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void nbjoueur(){
|
|
||||||
|
|
||||||
|
int nbjoueur(){
|
||||||
int x = 100, xx = 250, y = 150, l = 30, h = 30, angle1 = 20, angle2 = 30;
|
int x = 100, xx = 250, y = 150, l = 30, h = 30, angle1 = 20, angle2 = 30;
|
||||||
ChoisirCouleurDessin(CouleurParNom("Black"));
|
ChoisirCouleurDessin(CouleurParNom("Black"));
|
||||||
DessinerSegment(x, y, xx, y);
|
DessinerSegment(x, y, xx, y);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#define NBJOUEUR_H
|
#define NBJOUEUR_H
|
||||||
|
|
||||||
|
|
||||||
void nbjoueur();
|
int nbjoueur();
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
#include <graph.h>
|
#include <graph.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Fonction qui permet de déssiner le bouton du joueur contre IA
|
* Fonction qui permet de déssiner le bouton du joueur contre IA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void nbjoueur2(){
|
|
||||||
|
|
||||||
|
int nbjoueur2(){
|
||||||
int x = 400, xx = 550, y = 150, l = 30, h = 30, angle1 = 20, angle2 = 30;
|
int x = 400, xx = 550, y = 150, l = 30, h = 30, angle1 = 20, angle2 = 30;
|
||||||
ChoisirCouleurDessin(CouleurParNom("Black"));
|
ChoisirCouleurDessin(CouleurParNom("Black"));
|
||||||
DessinerSegment(x, y, xx, y);
|
DessinerSegment(x, y, xx, y);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#define NBJOUEUR2_H
|
#define NBJOUEUR2_H
|
||||||
|
|
||||||
|
|
||||||
void nbjoueur2();
|
int nbjoueur2();
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
6
taille.c
6
taille.c
@@ -82,5 +82,7 @@ int GererChoixTaille(){
|
|||||||
taille = 9;
|
taille = 9;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return taille;
|
if(taille != 0){
|
||||||
}
|
return taille;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
#include "initialisation.h"
|
#include "initialisation.h"
|
||||||
|
|
||||||
|
|
||||||
void VerifBlock1(int SourisX, int SourisY, int maxX, int maxY, int taille, int* coordoner){
|
int VerifBlock1(int SourisX, int SourisY, int maxX, int maxY, int taille, int* coordoner){
|
||||||
int placementX = 0, placementY = 0;
|
int placementX = 0, placementY = 0;
|
||||||
if(SourisX >= 50 && SourisX <= maxX && SourisY >= 100 && SourisY <= maxY){
|
if(SourisX >= 50 && SourisX <= maxX && SourisY >= 100 && SourisY <= maxY){
|
||||||
placementX = initialisationXbox(SourisX, maxX, taille);
|
placementX = initialisationXbox(SourisX, maxX, taille);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#ifndef VERIFICATIONBLOCK_H
|
#ifndef VERIFICATIONBLOCK_H
|
||||||
#define VERIFICATIONBLOCK_H
|
#define VERIFICATIONBLOCK_H
|
||||||
|
|
||||||
void VerifBlock1(int SourisX, int SourisY, int maxX, int maxY, int taille, int* coordoner);
|
int VerifBlock1(int SourisX, int SourisY, int maxX, int maxY, int taille, int* coordoner);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user