ajout des block mais pas fini car plus de temps de semaine donc travaille a la maison requis
This commit is contained in:
5
Makefile
5
Makefile
@@ -17,6 +17,7 @@ OFILES = taille.o \
|
|||||||
initialisation.o \
|
initialisation.o \
|
||||||
coordoner.o \
|
coordoner.o \
|
||||||
effacehaut.o \
|
effacehaut.o \
|
||||||
|
verificationblock.o \
|
||||||
main.o
|
main.o
|
||||||
|
|
||||||
|
|
||||||
@@ -34,11 +35,13 @@ effacehaut.o : effacehaut.h
|
|||||||
|
|
||||||
coordoner.o : coordoner.h
|
coordoner.o : coordoner.h
|
||||||
|
|
||||||
|
verificationblock.o : verificationblock.h
|
||||||
|
|
||||||
initialisation.o : initialisation.h
|
initialisation.o : initialisation.h
|
||||||
|
|
||||||
nbjoueur.o : nbjoueur.h
|
nbjoueur.o : nbjoueur.h
|
||||||
|
|
||||||
comportementJCJ.o : comportementJCJ.h definirMaxXY.h initialisation.h coordoner.h effacehaut.h
|
comportementJCJ.o : comportementJCJ.h definirMaxXY.h initialisation.h coordoner.h effacehaut.h verificationblock.h
|
||||||
|
|
||||||
comportementJCIA.o : comportementJCIA.h
|
comportementJCIA.o : comportementJCIA.h
|
||||||
|
|
||||||
|
|||||||
@@ -7,13 +7,15 @@
|
|||||||
#include "initialisation.h"
|
#include "initialisation.h"
|
||||||
#include "coordoner.h"
|
#include "coordoner.h"
|
||||||
#include "effacehaut.h"
|
#include "effacehaut.h"
|
||||||
|
#include "verificationblock.h"
|
||||||
|
|
||||||
|
|
||||||
void compJCJ(int taille){
|
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 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, joueurx1 = 0, joueury1 = 0, joueurx2 = 0, joueury2 = 0;
|
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];
|
||||||
|
int empblock[4] = {0, 0, 0, 0};
|
||||||
maxX = DefMaxX(taille);
|
maxX = DefMaxX(taille);
|
||||||
maxY = DefMaxY(taille);
|
maxY = DefMaxY(taille);
|
||||||
for(tabx = 0; tabx < taille + 2; tabx++){
|
for(tabx = 0; tabx < taille + 2; tabx++){
|
||||||
@@ -51,7 +53,7 @@ void compJCJ(int taille){
|
|||||||
if(SourisX >= 50 && SourisX <= maxX && SourisY >= 100 && SourisY <= maxY){
|
if(SourisX >= 50 && SourisX <= maxX && SourisY >= 100 && SourisY <= maxY){
|
||||||
ChargerSprite("pion2.png");
|
ChargerSprite("pion2.png");
|
||||||
joueurx2 = initialisationX(SourisX, maxX, taille);
|
joueurx2 = initialisationX(SourisX, maxX, taille);
|
||||||
joueury2 = initialisationY(SourisY, maxX, taille);
|
joueury2 = initialisationY(SourisY, maxY, taille);
|
||||||
if(grille[joueury2][joueurx2] != 1){
|
if(grille[joueury2][joueurx2] != 1){
|
||||||
emplacementcooX2 = coordonerX(SourisX);
|
emplacementcooX2 = coordonerX(SourisX);
|
||||||
emplacementcooY2 = coordonerY(SourisY);
|
emplacementcooY2 = coordonerY(SourisY);
|
||||||
@@ -70,20 +72,27 @@ void compJCJ(int taille){
|
|||||||
Efface();
|
Efface();
|
||||||
EcrireTexte(30, 40, "Tour du joueur 1", 2);
|
EcrireTexte(30, 40, "Tour du joueur 1", 2);
|
||||||
tour++;
|
tour++;
|
||||||
}else if(tour == 2){
|
}else if(tour == 1){
|
||||||
Efface();
|
Efface();
|
||||||
EcrireTexte(30, 40, "Joueur 1 place le bloc", 2);
|
EcrireTexte(30, 40, "Joueur 1 place le bloc", 2);
|
||||||
while(1){
|
while(placer == 1){
|
||||||
|
VerifBlock1(maxX, maxY, taille, empblock);
|
||||||
|
if(empblock[2] == 6){
|
||||||
|
printf("%d, %d", empblock[0], empblock[1]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
placer = 1;
|
||||||
|
tour++;
|
||||||
|
}else if(tour == 2){
|
||||||
|
Efface();
|
||||||
|
EcrireTexte(30, 40, "Tour du joueur 2", 2);
|
||||||
|
while(1){}
|
||||||
tour++;
|
tour++;
|
||||||
}else if(tour == 3){
|
}else if(tour == 3){
|
||||||
Efface();
|
|
||||||
EcrireTexte(30, 40, "Tour du joueur 2", 2);
|
|
||||||
tour++;
|
|
||||||
}else if(tour == 4){
|
|
||||||
Efface();
|
Efface();
|
||||||
EcrireTexte(30, 40, "Joueur 2 place le bloc", 2);
|
EcrireTexte(30, 40, "Joueur 2 place le bloc", 2);
|
||||||
tour++;
|
while(1){}
|
||||||
|
tour = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,3 +25,34 @@ int initialisationY(int SourisY, int maxY, int taille){
|
|||||||
}
|
}
|
||||||
return casejoueur;
|
return casejoueur;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int initialisationXbox(int SourisX, int maxX, int taille){
|
||||||
|
int caseblock = 0, x = 0, y = 50, verou = 0;
|
||||||
|
for(x = 0; x <= taille; x++){
|
||||||
|
if(SourisX >= 50 && SourisX <= maxX){
|
||||||
|
if(SourisX <= y && verou == 0){
|
||||||
|
caseblock = x;
|
||||||
|
verou++;
|
||||||
|
}
|
||||||
|
y += 50;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return caseblock;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int initialisationYbox(int SourisY, int maxY, int taille){
|
||||||
|
int caseblock = 0, x = 0, y = 100, verou = 0;
|
||||||
|
for(x = 0; x <= taille; x++){
|
||||||
|
if(SourisY >= 100 && SourisY <= maxY){
|
||||||
|
if(SourisY <= y && verou == 0){
|
||||||
|
caseblock = x;
|
||||||
|
verou++;
|
||||||
|
}
|
||||||
|
y += 50;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return caseblock;
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,7 +3,10 @@
|
|||||||
|
|
||||||
int initialisationX(int SourisX, int maxX, int taille);
|
int initialisationX(int SourisX, int maxX, int taille);
|
||||||
|
|
||||||
|
|
||||||
int initialisationY(int SourisY, int maxY, int taille);
|
int initialisationY(int SourisY, int maxY, int taille);
|
||||||
|
|
||||||
|
int initialisationXbox(int SourisX, int maxX, int taille);
|
||||||
|
|
||||||
|
int initialisationYbox(int SourisY, int maxY, int taille);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
19
verificationblock.c
Normal file
19
verificationblock.c
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#include <graph.h>
|
||||||
|
|
||||||
|
#include "initialisation.h"
|
||||||
|
|
||||||
|
|
||||||
|
int VerifBlock1(int maxX, int maxY, int taille, int* coordoner){
|
||||||
|
int SourisX = 0, SourisY = 0, placement = 1, placementX = 0, placementY = 0;
|
||||||
|
if(SourisCliquee()){
|
||||||
|
SourisX = _X;
|
||||||
|
SourisY = _Y;
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
coordoner[2] = 6;
|
||||||
|
}
|
||||||
7
verificationblock.h
Normal file
7
verificationblock.h
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#ifndef VERIFICATIONBLOCK_H
|
||||||
|
#define VERIFICATIONBLOCK_H
|
||||||
|
|
||||||
|
int VerifBlock1(int maxX, int maxY, int taille, int* coordoner);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user