Ajout de plusieur fonction mais en tout cas meintenant on peut placer les pion a leur place de base via le joueur

This commit is contained in:
2024-11-15 15:45:18 +01:00
parent f2880c2bbf
commit 9a446cfafa
8 changed files with 126 additions and 15 deletions

View File

@@ -5,11 +5,14 @@
#include "definirMaxXY.h"
#include "initialisation.h"
#include "coordoner.h"
#include "effacehaut.h"
void compJCJ(int taille){
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 maxX = 0, maxY = 0, joueurx1 = 0, joueury1 = 0, joueurx2 = 0, joueury2 = 0;
int emplacementcooX1 = 0, emplacementcooX2 = 0, emplacementcooY1 = 0, emplacementcooY2 = 0;
int grille[taille+2][taille+2];
maxX = DefMaxX(taille);
maxY = DefMaxY(taille);
@@ -28,23 +31,57 @@ void compJCJ(int taille){
if(SourisCliquee()){
SourisX = _X;
SourisY = _Y;
printf("%d, %d\n", SourisX, SourisY);
printf("max X Y : %d, %d\n", maxX, maxY);
}
if(initialiser == 0){
if(SourisX >= 200 && SourisX <= maxX && SourisY >= 250 && SourisY <= maxY){
printf("entre max\n");
initialisation(SourisX, SourisY, maxX, maxY);
if(SourisX >= 50 && SourisX <= maxX && SourisY >= 100 && SourisY <= maxY){
ChargerSprite("pion1.png");
joueurx1 = initialisationX(SourisX, maxX, taille);
joueury1 = initialisationY(SourisY, maxY, taille);
emplacementcooX1 = coordonerX(SourisX);
emplacementcooY1 = coordonerY(SourisY);
AfficherSprite(1, emplacementcooX1, emplacementcooY1);
grille[joueury1][joueurx1] = 1;
initialiser++;
SourisX = 0;
SourisY = 0;
Efface();
EcrireTexte(30, 40, "Joueur 2 choisissez l'emplacement de base du pion 2", 1);
}
}else if (initialiser == 1){
if(SourisX >= 50 && SourisX <= maxX && SourisY >= 100 && SourisY <= maxY){
ChargerSprite("pion2.png");
joueurx2 = initialisationX(SourisX, maxX, taille);
joueury2 = initialisationY(SourisY, maxX, taille);
if(grille[joueury2][joueurx2] != 1){
emplacementcooX2 = coordonerX(SourisX);
emplacementcooY2 = coordonerY(SourisY);
AfficherSprite(2, emplacementcooX2, emplacementcooY2);
grille[joueury2][joueurx2] = 2;
initialiser++;
initi++;
}
SourisX = 0;
SourisY = 0;
}
}
}
while(fin == 0){
if(tour == 0){
ChoisirCouleurDessin(CouleurParNom("white"));
RemplirRectangle(0, 0, 300, 50);
ChoisirCouleurDessin(CouleurParNom("black"));
Efface();
EcrireTexte(30, 40, "Tour du joueur 1", 2);
while(1){}
tour++;
}else if(tour == 2){
Efface();
EcrireTexte(30, 40, "Joueur 1 place le bloc", 2);
tour++;
}else if(tour == 3){
Efface();
EcrireTexte(30, 40, "Tour du joueur 2", 2);
tour++;
}else if(tour == 4){
Efface();
EcrireTexte(30, 40, "Joueur 2 place le bloc", 2);
tour++;
}
}