diff --git a/src/IAEngine.c b/src/IAEngine.c index e31e74e..c8bd87d 100644 --- a/src/IAEngine.c +++ b/src/IAEngine.c @@ -3,16 +3,6 @@ #include #include "IAEngine.h" -#define NB_BLOCS_LARGEUR 20 -#define NB_BLOCS_HAUTEUR 20 - -struct point -{ - int x,y; -}POINT; - - - int FindPath(ARENA_H_TILE *arena,PLAYER *player1, PLAYER *player2) { @@ -27,18 +17,18 @@ int FindPath(ARENA_H_TILE *arena,PLAYER *player1, PLAYER *player2) //1 vers la gauche - NOEUD * n1 =NULL; - n1=(NOEUD*)malloc(sizeof(NOEUD)); + NOEUD *n1 =NULL; + n1=malloc(sizeof(NOEUD)); - posX = player2->PositionX -1; - posY = player2->PositionY ; + posX = player2->PositionX-1; + posY = player2->PositionY; n1->min=3000; n1->compteur=0; n1->ParentX = player2->PositionX; n1->ParentY = player2->PositionY; - if(((posX >= 0) && (posX < NB_BLOCS_LARGEUR ))&& ((posY >= 0) && (posY < NB_BLOCS_HAUTEUR))) + if(((posX >= 0) && (posX < A_WIDTH ))&& ((posY >= 0) && (posY < A_HEIGHT))) { if(getTileTypeID(arena,posX,posY) == 0) { @@ -56,7 +46,7 @@ int FindPath(ARENA_H_TILE *arena,PLAYER *player1, PLAYER *player2) posX = player2->PositionX; posY = player2->PositionY - 1; - if(((posX >=0) && (posX = 0) && (posY < NB_BLOCS_HAUTEUR))) + if(((posX >=0) && (posX < A_WIDTH ))&& ((posY >= 0) && (posY < A_HEIGHT))) { if(getTileTypeID(arena,posX,posY) == 0) @@ -72,7 +62,7 @@ int FindPath(ARENA_H_TILE *arena,PLAYER *player1, PLAYER *player2) posX = player2->PositionX; posY = player2->PositionY + 1; - if(((posX >= 0) && (posX < NB_BLOCS_LARGEUR ))&& ((posY >=0) && (posY < NB_BLOCS_HAUTEUR))) + if(((posX >= 0) && (posX < A_WIDTH ))&& ((posY >=0) && (posY < A_HEIGHT))) { if(getTileTypeID(arena,posX,posY) == 0) { @@ -87,7 +77,7 @@ int FindPath(ARENA_H_TILE *arena,PLAYER *player1, PLAYER *player2) posX = player2->PositionX +1; posY = player2->PositionY ; - if(((posX >= 0) && (posX < NB_BLOCS_LARGEUR ))&& ((posY >= 0) && (posY < NB_BLOCS_HAUTEUR))) + if(((posX >= 0) && (posX < A_WIDTH ))&& ((posY >= 0) && (posY < A_HEIGHT))) { if(getTileTypeID(arena,posX,posY) == 0) @@ -217,7 +207,7 @@ NOEUD *CalculatePath(ARENA_H_TILE *arena,int posX, int posY,NOEUD *n1,PLAYER *p int ID; - if(((posX - 1 >= 0) && (posX - 1 < NB_BLOCS_LARGEUR ))&& ((posY >= 0) && (posY < NB_BLOCS_HAUTEUR))) + if(((posX - 1 >= 0) && (posX - 1 < A_WIDTH ))&& ((posY >= 0) && (posY < A_HEIGHT))) { if((n1->ParentX == player1->PositionX ) && ( n1->ParentY == player1->PositionY)) { @@ -278,7 +268,7 @@ NOEUD *CalculatePath(ARENA_H_TILE *arena,int posX, int posY,NOEUD *n1,PLAYER *p return n1; } - if(((posX +1 >= 0) && (posX + 1 < NB_BLOCS_LARGEUR ))&& ((posY >= 0) && (posY < NB_BLOCS_HAUTEUR))) + if(((posX +1 >= 0) && (posX + 1 < A_WIDTH ))&& ((posY >= 0) && (posY < A_HEIGHT))) { if((n1->ParentX == player1->PositionX ) && ( n1->ParentY == player1->PositionY)) { @@ -324,7 +314,7 @@ NOEUD *CalculatePath(ARENA_H_TILE *arena,int posX, int posY,NOEUD *n1,PLAYER *p } - if(((posX >= 0) && (posX < NB_BLOCS_LARGEUR ))&& ((posY + 1 >=0) && (posY + 1= 0) && (posX < A_WIDTH ))&& ((posY + 1 >=0) && (posY + 1ParentX == player1->PositionX ) && ( n1->ParentY == player1->PositionY)) { @@ -367,7 +357,7 @@ NOEUD *CalculatePath(ARENA_H_TILE *arena,int posX, int posY,NOEUD *n1,PLAYER *p } - if(((posX >= 0) && (posX < NB_BLOCS_LARGEUR ))&& ((posY - 1 >= 0) && (posY - 1 < NB_BLOCS_HAUTEUR))) + if(((posX >= 0) && (posX < A_WIDTH ))&& ((posY - 1 >= 0) && (posY - 1 < A_HEIGHT))) { if((n1->ParentX == player1->PositionX ) && ( n1->ParentY == player1->PositionY)) { diff --git a/src/IAEngine.h b/src/IAEngine.h index 7604f05..5dc69d0 100644 --- a/src/IAEngine.h +++ b/src/IAEngine.h @@ -5,8 +5,7 @@ #ifndef IAENGINE_H_ #define IAENGINE_H_ -typedef struct noeud -{ +typedef struct noeud{ int compteur, min, cout_f; // int ParentX; @@ -14,6 +13,11 @@ typedef struct noeud // 'adresse' du parent (qui sera toujours dans la map fermée) }NOEUD; +/* +typedef struct point{ + int x,y; +}POINT; +*/ int FindShortestPath(int Player1PositionX, int Player1PositionY, int Player2PositionX, int Player2PositionY); //int IAEngine(PLAYER * player1, PLAYER * player2); diff --git a/src/arenaEngine.c b/src/arenaEngine.c index 5eb77ab..a0a4477 100644 --- a/src/arenaEngine.c +++ b/src/arenaEngine.c @@ -111,7 +111,7 @@ PLAYER *createPlayerList(void) { p1->texture[RIGHT] = IMG_Load("data/sprite_ia_3.png"); p1->suiv = p2; strcpy(p1->Name,"SKY-NUT"); - p1->Race = random_lim(4); + p1->Race = random_lim(3)+1; switch(race) {