diff --git a/Adventurer/adventurer1_32x32.png b/Adventurer/adventurer1_32x32.png new file mode 100755 index 0000000..0dc5a22 Binary files /dev/null and b/Adventurer/adventurer1_32x32.png differ diff --git a/Adventurer/adventurer_back_32x32.png b/Adventurer/adventurer_back_32x32.png new file mode 100755 index 0000000..5e3a562 Binary files /dev/null and b/Adventurer/adventurer_back_32x32.png differ diff --git a/Adventurer/adventurer_left_32x32.png b/Adventurer/adventurer_left_32x32.png new file mode 100755 index 0000000..be24a73 Binary files /dev/null and b/Adventurer/adventurer_left_32x32.png differ diff --git a/Adventurer/adventurer_right_32x32.png b/Adventurer/adventurer_right_32x32.png new file mode 100755 index 0000000..63045a1 Binary files /dev/null and b/Adventurer/adventurer_right_32x32.png differ diff --git a/Adventurer1/adventurer1_32x32.png b/Adventurer1/adventurer1_32x32.png new file mode 100755 index 0000000..0dc5a22 Binary files /dev/null and b/Adventurer1/adventurer1_32x32.png differ diff --git a/Adventurer1/adventurer_back_32x32.png b/Adventurer1/adventurer_back_32x32.png new file mode 100755 index 0000000..5e3a562 Binary files /dev/null and b/Adventurer1/adventurer_back_32x32.png differ diff --git a/Adventurer1/adventurer_left_32x32.png b/Adventurer1/adventurer_left_32x32.png new file mode 100755 index 0000000..be24a73 Binary files /dev/null and b/Adventurer1/adventurer_left_32x32.png differ diff --git a/adventurer_resize.png b/Adventurer1/adventurer_resize.png similarity index 100% rename from adventurer_resize.png rename to Adventurer1/adventurer_resize.png diff --git a/Adventurer1/adventurer_right_32x32.png b/Adventurer1/adventurer_right_32x32.png new file mode 100755 index 0000000..63045a1 Binary files /dev/null and b/Adventurer1/adventurer_right_32x32.png differ diff --git a/Adventurer2/adventurer2_32x32.png b/Adventurer2/adventurer2_32x32.png new file mode 100755 index 0000000..d46e57e Binary files /dev/null and b/Adventurer2/adventurer2_32x32.png differ diff --git a/Adventurer2/adventurer2_back_32x32.png b/Adventurer2/adventurer2_back_32x32.png new file mode 100755 index 0000000..f5b591b Binary files /dev/null and b/Adventurer2/adventurer2_back_32x32.png differ diff --git a/Adventurer2/adventurer2_left_32x32.png b/Adventurer2/adventurer2_left_32x32.png new file mode 100755 index 0000000..f5a8e29 Binary files /dev/null and b/Adventurer2/adventurer2_left_32x32.png differ diff --git a/Adventurer2/adventurer2_right_32x32.png b/Adventurer2/adventurer2_right_32x32.png new file mode 100755 index 0000000..71c2f64 Binary files /dev/null and b/Adventurer2/adventurer2_right_32x32.png differ diff --git a/Adventurer2/playerInterface.h b/Adventurer2/playerInterface.h new file mode 100644 index 0000000..6f3e0da --- /dev/null +++ b/Adventurer2/playerInterface.h @@ -0,0 +1,57 @@ +/* + * playerInterface.h + * + * Created on: 17 juin 2018 + * Author: isen + */ +#include "arenaEngine.h" + +#ifndef PLAYERINTERFACE_H_ +#define PLAYERINTERFACE_H_ + +/** Structure d'un joueur (IA ou utilisateur) + * + * */ +typedef struct Player +{ + int Id; + char Name[35]; + //char Race[20]; + int Race; + + int HealthPoints; + int AttacksPoints; + int DefensePoints; + + int PositionX; + int PositionY; + + //char Weapons[Max_Weapons]; + + //int Coins; + + struct Player * suiv; + +}PLAYER; + +//Prototypes + +PLAYER* createPlayer(int Id); +PLAYER* insertRightPlaceRecursive(PLAYER* Head, PLAYER* Element); +void displayList(PLAYER * Head); +PLAYER * freeElement(PLAYER *Head, int Id); +PLAYER * freeList(PLAYER *Head); + +PLAYER * SearchPlayer(PLAYER *Head, int idPlayer); +void AttackPlayer( PLAYER *player1, PLAYER *player2); +//void ActionPlayer(PLAYER * player, int action); +void ActionPlayer(ARENA_H_TILE* arena,PLAYER * player, int action); + +int NumberPlayerAlive(PLAYER *Head); +int getEvent(void); + +#define ARENAMAX 20 + + + +#endif /* PLAYERINTERFACE_H_ */ diff --git a/Debug/ArenaWarSurvival b/Debug/ArenaWarSurvival new file mode 100755 index 0000000..4bde4e2 Binary files /dev/null and b/Debug/ArenaWarSurvival differ diff --git a/Debug/makefile b/Debug/makefile new file mode 100644 index 0000000..facab4b --- /dev/null +++ b/Debug/makefile @@ -0,0 +1,42 @@ +################################################################################ +# Automatically-generated file. Do not edit! +################################################################################ + +-include ../makefile.init + +RM := rm -rf + +# All of the sources participating in the build are defined here +-include sources.mk +-include subdir.mk +-include objects.mk + +ifneq ($(MAKECMDGOALS),clean) +ifneq ($(strip $(C_DEPS)),) +-include $(C_DEPS) +endif +endif + +-include ../makefile.defs + +# Add inputs and outputs from these tool invocations to the build variables + +# All Target +all: ArenaWarSurvival + +# Tool invocations +ArenaWarSurvival: $(OBJS) $(USER_OBJS) + @echo 'Building target: $@' + @echo 'Invoking: GCC C Linker' + gcc -o "ArenaWarSurvival" $(OBJS) $(USER_OBJS) $(LIBS) + @echo 'Finished building target: $@' + @echo ' ' + +# Other Targets +clean: + -$(RM) $(EXECUTABLES)$(OBJS)$(C_DEPS) ArenaWarSurvival + -@echo ' ' + +.PHONY: all clean dependents + +-include ../makefile.targets diff --git a/Debug/objects.mk b/Debug/objects.mk new file mode 100644 index 0000000..9ae6fd9 --- /dev/null +++ b/Debug/objects.mk @@ -0,0 +1,8 @@ +################################################################################ +# Automatically-generated file. Do not edit! +################################################################################ + +USER_OBJS := + +LIBS := -lSDL2 -lSDL2_image -lSDL2main + diff --git a/Debug/sources.mk b/Debug/sources.mk new file mode 100644 index 0000000..3ce86e2 --- /dev/null +++ b/Debug/sources.mk @@ -0,0 +1,17 @@ +################################################################################ +# Automatically-generated file. Do not edit! +################################################################################ + +OBJ_SRCS := +ASM_SRCS := +C_SRCS := +O_SRCS := +S_UPPER_SRCS := +EXECUTABLES := +OBJS := +C_DEPS := + +# Every subdirectory with source files must be described here +SUBDIRS := \ +. \ + diff --git a/Debug/subdir.mk b/Debug/subdir.mk new file mode 100644 index 0000000..00b9e27 --- /dev/null +++ b/Debug/subdir.mk @@ -0,0 +1,36 @@ +################################################################################ +# Automatically-generated file. Do not edit! +################################################################################ + +# Add inputs and outputs from these tool invocations to the build variables +C_SRCS += \ +../IAEngine.c \ +../arenaEngine.c \ +../fileHandler.c \ +../main.c \ +../playerInterface.c + +OBJS += \ +./IAEngine.o \ +./arenaEngine.o \ +./fileHandler.o \ +./main.o \ +./playerInterface.o + +C_DEPS += \ +./IAEngine.d \ +./arenaEngine.d \ +./fileHandler.d \ +./main.d \ +./playerInterface.d + + +# Each subdirectory must supply rules for building sources it contributes +%.o: ../%.c + @echo 'Building file: $<' + @echo 'Invoking: GCC C Compiler' + gcc -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -o "$@" "$<" + @echo 'Finished building: $<' + @echo ' ' + + diff --git a/IA1/adventurer2_32x32.png b/IA1/adventurer2_32x32.png new file mode 100755 index 0000000..d46e57e Binary files /dev/null and b/IA1/adventurer2_32x32.png differ diff --git a/IA1/adventurer2_back_32x32.png b/IA1/adventurer2_back_32x32.png new file mode 100755 index 0000000..f5b591b Binary files /dev/null and b/IA1/adventurer2_back_32x32.png differ diff --git a/IA1/adventurer2_left_32x32.png b/IA1/adventurer2_left_32x32.png new file mode 100755 index 0000000..f5a8e29 Binary files /dev/null and b/IA1/adventurer2_left_32x32.png differ diff --git a/IA1/adventurer2_right_32x32.png b/IA1/adventurer2_right_32x32.png new file mode 100755 index 0000000..71c2f64 Binary files /dev/null and b/IA1/adventurer2_right_32x32.png differ diff --git a/IAEngine.c b/IAEngine.c index 1381e23..a02381d 100644 --- a/IAEngine.c +++ b/IAEngine.c @@ -16,6 +16,20 @@ #include #include +enum {HAUT, DROITE, BAS, GAUCHE}; +#define NB_BLOCS_LARGEUR 20 +#define NB_BLOCS_HAUTEUR 20 + + +struct point +{ + int x,y; +}POINT; + + + + + int IAEngine(ARENA_H_TILE* arena,PLAYER * player1, PLAYER * player2) @@ -24,14 +38,16 @@ int IAEngine(ARENA_H_TILE* arena,PLAYER * player1, PLAYER * player2) //Player 1 est le joueur, player 2 le bot + if((player1 != NULL) & (player2 !=NULL)) { //On récupère les positions des 2 joueurs . L'IA sait où est le joueur int action; - action = FindShortestPath(player1->PositionX,player1->PositionY,player2->PositionX,player2->PositionY); + //action = FindShortestPath(player1->PositionX,player1->PositionY,player2->PositionX,player2->PositionY); + action = FindPath(arena,player1,player2); printf("Tour de l'IA\n"); if(action == 5) { @@ -43,20 +59,390 @@ int IAEngine(ARENA_H_TILE* arena,PLAYER * player1, PLAYER * player2) } //On vérifie si les 2 joueurs sont à côté pour attaquer printf("Vérification position\n"); - action = FindShortestPath(player1->PositionX,player1->PositionY,player2->PositionX,player2->PositionY); + /*action = FindShortestPath(player1->PositionX,player1->PositionY,player2->PositionX,player2->PositionY); if(action == 5) { AttackPlayer(player2,player1); - } + }*/ } return 0; } +int FindPath(ARENA_H_TILE* arena,PLAYER * player1, PLAYER * player2) +{ + + int action; + + int compteur = 0; + int minH=1000,minB=1000,minG=1000,minD=1000; + int posX=0; + int posY=0; + //1 vers la gauche + NOEUD * n1 =NULL; + n1=(NOEUD*)malloc(sizeof(NOEUD)); + + 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(getTileTypeID(arena,posX,posY) == 0) + { + n1->compteur = n1->compteur+1; + //direction = GAUCHE; + n1=CalculatePath(arena,posX,posY,n1,player1,player2,compteur,0,minG); + minG=n1->min; + printf("minG = %i\n",minG); + } + } + + + + //1 vers le haut + posX = player2->PositionX; + posY = player2->PositionY - 1; + + if(((posX >=0) && (posX = 0) && (posY < NB_BLOCS_HAUTEUR))) + { + + if(getTileTypeID(arena,posX,posY) == 0) + { + //direction = HAUT; + + n1=CalculatePath(arena,posX,posY,n1,player1,player2,compteur,0,minH); + minH=n1->min; + + } + } + //1 vers le bas + posX = player2->PositionX; + posY = player2->PositionY + 1; + + if(((posX >= 0) && (posX < NB_BLOCS_LARGEUR ))&& ((posY >=0) && (posY < NB_BLOCS_HAUTEUR))) + { + if(getTileTypeID(arena,posX,posY) == 0) + { + //direction = BAS; + n1=CalculatePath(arena,posX,posY,n1,player1,player2,compteur,0,minB); + minB=n1->min; + + } + } + + //1 vers la droite + posX = player2->PositionX +1; + posY = player2->PositionY ; + + if(((posX >= 0) && (posX < NB_BLOCS_LARGEUR ))&& ((posY >= 0) && (posY < NB_BLOCS_HAUTEUR))) + { + if(getTileTypeID(arena,posX,posY) == 0) + + { + //direction = DROITE; + + n1=CalculatePath(arena,posX,posY,n1,player1,player2,compteur,0,minD); + minD=n1->min; + + } + } + + printf("minG = %i\n",minG); + printf("minH = %i\n",minH); + printf("minB = %i\n",minB); + printf("minD = %i\n",minD); + + + if(minG < minD) + { + if(minG < minH) + { + if(minG <= minB) + { + printf("ACTION GAUCHE 1\n"); + action = 4; + } + else + { + printf("ACTION BAS 1\n"); + action = 3; + } + } + else + { + if(minH < minB) + { + printf("ACTION HAUT 1\n"); + action = 1; + } + else + { + printf("ACTION BAS 2\n"); + action = 3; + } + + } + } + else + { + if(minD < minH) + { + if(minD < minB) + { + printf("ACTION DROITE 1\n"); + action = 2; + } + else + { + printf("ACTION BAS 3\n"); + action = 3; + } + } + else + { + if(minH < minB) + { + printf("ACTION HAUT 2\n"); + action = 1; + } + else + { + printf("ACTION BAS 4\n"); + action = 3; + } + + } + } + + free(n1); + return action; + +} + + +int distance(int x1, int y1, int x2, int y2) +{ + /* distance euclidienne */ + int distX = abs(x2-x1); + int distY = abs(y2-y1); + return distX + distY; + + /* carré de la distance euclidienne */ + /* return (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2); */ +} + + +NOEUD * CalculatePath(ARENA_H_TILE* arena,int posX, int posY,NOEUD * n1,PLAYER * player1,PLAYER * player2, int compteur, int dist,int min) +{ + + int ID; + + if(((posX - 1 >= 0) && (posX - 1 < NB_BLOCS_LARGEUR ))&& ((posY >= 0) && (posY < NB_BLOCS_HAUTEUR))) + { + if((n1->ParentX == player1->PositionX ) && ( n1->ParentY == player1->PositionY)) + { + printf("n1->ParentX - 1 = %i et n1->ParentY =%i\n",n1->ParentX - 1 ,n1->ParentY); + printf("RETURN N1\n"); + return n1; + } + + ID=getTileTypeID(arena,posX - 1,posY); + + if(( ID== 0) && (posX-1 != n1->ParentX)) + { + n1->ParentX = posX - 1; + //Vers la gauche + n1->compteur = n1->compteur + 1; + //compteur = compteur + 1; + printf("*****111*****\n"); + + printf("Position Player1 X: %i et Y: %i\n",player1->PositionX,player1->PositionY); + printf("Position n1 player2 X: %i et Y: %i\n",n1->ParentX,n1->ParentY); + printf("Position Player2 posX: %i et posY: %i\n",posX,posY); + printf("ID de posx - 1 et posY : %i\n",ID); + + //while((posX - 1 != player1->PositionX) && (posY != player1->PositionY)) + while((posX - 1 != player1->PositionX) || (posY != player1->PositionY)) + { + + /*printf("*****222*****\n"); + printf("Position Player1 X: %i et Y: %i\n",player1->PositionX,player1->PositionY); + printf("Position n1 player2 X: %i et Y: %i\n",n1->ParentX,n1->ParentY); + printf("Position Player2 posX: %i et posY: %i\n",posX,posY); + printf("ID de posx - 1 et posY : %i\n",ID);*/ + + n1=CalculatePath(arena,posX - 1,posY,n1,player1,player2,compteur,dist,min); + + //Post-Traitement + //Calcul du "poids" du chemin (nb de coups) + + dist = distance(player1->PositionX,player1->PositionY,posX - 1,posY) + n1->compteur; + + if(dist < n1->min) + { + printf("On rentre dans le min\n"); + n1->min=dist; + } + return n1; + } + } + } + + printf("n1->compteur : %i \n",n1->compteur ); + printf("abs(player2->PositionX - player1->PositionY)-1 : %i \n",abs(player2->PositionX - player1->PositionY)-1 ); + if(n1->compteur == abs(player2->PositionX - player1->PositionY)-1) + { + printf("Chemin plus court trouvé\n"); + n1->min=n1->compteur; + printf("n1->min : %i \n",n1->min ); + return n1; + } + + if(((posX +1 >= 0) && (posX + 1 < NB_BLOCS_LARGEUR ))&& ((posY >= 0) && (posY < NB_BLOCS_HAUTEUR))) + { + if((n1->ParentX == player1->PositionX ) && ( n1->ParentY == player1->PositionY)) + { + printf("n1->ParentX + 1 = %i et n1->ParentY =%i\n",n1->ParentX + 1 ,n1->ParentY); + printf("RETURN N1\n"); + return n1; + } + + + if((getTileTypeID(arena,posX + 1 ,posY) == 0) && (posX + 1 != n1->ParentX)) + { + n1->ParentX = posX + 1; + //Vers la droite + n1->compteur = n1->compteur + 1; + //compteur = compteur + 1; + + //while((posX != player1->PositionX) && (posY != player1->PositionY)) + while((posX != player1->PositionX) || (posY != player1->PositionY)) + { + + n1=CalculatePath(arena,posX + 1,posY,n1,player1,player2,compteur,dist,min); + + //Post-Traitement + //Calcul du "poids" du chemin (nb de coups) + dist = distance(player1->PositionX,player1->PositionY,posX + 1,posY) + n1->compteur; + + printf("DIST = %i\n",dist); + if(dist < n1->min) + { + n1->min=dist; + } + } + } + } + + printf("n1->compteur : %i \n",n1->compteur ); + printf("abs(player2->PositionX - player1->PositionY)-1 : %i \n",abs(player2->PositionX - player1->PositionY)-1 ); + if(n1->compteur == abs(player2->PositionX - player1->PositionY)-1) + { + printf("Chemin plus court trouvé\n"); + n1->min=n1->compteur; + return n1; + } + + + if(((posX >= 0) && (posX < NB_BLOCS_LARGEUR ))&& ((posY + 1 >=0) && (posY + 1ParentX == player1->PositionX ) && ( n1->ParentY == player1->PositionY)) + { + printf("n1->ParentX = %i et n1->ParentY +1 =%i\n",n1->ParentX ,n1->ParentY+1); + printf("RETURN N1\n"); + return n1; + } + + if((getTileTypeID(arena,posX,posY + 1) == 0) && (posY + 1 != n1->ParentY)) + { + n1->ParentY = posY + 1; + + //Vers la bas + n1->compteur = n1->compteur + 1; + //compteur = compteur + 1; + + //while((posX != player1->PositionX) && (posY != player1->PositionY)) + while((posX != player1->PositionX) || (posY != player1->PositionY)) + { + n1=CalculatePath(arena,posX,posY + 1,n1,player1,player2,compteur,dist,min); + + //Post-Traitement + //Calcul du "poids" du chemin (nb de coups) + dist = distance(player1->PositionX,player1->PositionY,posX,posY + 1) + n1->compteur; + + if(dist < n1->min) + { + n1->min=dist; + } + } + } + } + printf("n1->compteur : %i \n",n1->compteur ); + printf("abs(player2->PositionX - player1->PositionY)-1 : %i \n",abs(player2->PositionX - player1->PositionY)-1 ); + if(n1->compteur == abs(player2->PositionX - player1->PositionY)-1) + { + printf("Chemin plus court trouvé\n"); + n1->min=n1->compteur; + return n1; + } + + + if(((posX >= 0) && (posX < NB_BLOCS_LARGEUR ))&& ((posY - 1 >= 0) && (posY - 1 < NB_BLOCS_HAUTEUR))) + { + if((n1->ParentX == player1->PositionX ) && ( n1->ParentY == player1->PositionY)) + { + printf("n1->ParentX = %i et n1->ParentY -1 =%i\n",n1->ParentX ,n1->ParentY - 1); + printf("RETURN N1\n"); + return n1; + } + + if((getTileTypeID(arena,posX,posY-1) == 0) && (posY - 1 != n1->ParentY)) + { + n1->ParentY = posY - 1; + //Vers la haut + n1->compteur = n1->compteur + 1; + //compteur = compteur + 1; + + //while((posX != player1->PositionX) && (posY != player1->PositionY)) + while((posX != player1->PositionX) || (posY != player1->PositionY)) + { + n1=CalculatePath(arena,posX,posY - 1,n1,player1,player2,compteur,dist,min); + + //Post-Traitement + //Calcul du "poids" du chemin (nb de coups) + dist = distance(player1->PositionX,player1->PositionY,posX,posY - 1) + n1->compteur; + + if(dist < n1->min) + { + n1->min=dist; + } + } + } + } + printf("n1->compteur : %i \n",n1->compteur ); + printf("abs(player2->PositionX - player1->PositionY)-1 : %i \n",abs(player2->PositionX - player1->PositionY)-1 ); + + if(n1->compteur == abs(player2->PositionX - player1->PositionY)-1) + { + printf("Chemin plus court trouvé\n"); + n1->min=n1->compteur; + return n1; + } + + printf("return n1\n"); + return n1; +} + + //Fonction de reflexion IA fonctionne mais les pierres et arbres sont bloquants @@ -68,7 +454,7 @@ int FindShortestPath(int Player1PositionX, int Player1PositionY, int Player2Posi int differenceX = abs(Player1PositionX - Player2PositionX); int differenceY = abs(Player1PositionY - Player2PositionY); -printf("DifferenceX : %i et DifferenceY : %i \n",differenceX,differenceY); + printf("DifferenceX : %i et DifferenceY : %i \n",differenceX,differenceY); int action=0; diff --git a/IAEngine.h b/IAEngine.h index ebdd0e5..f9cd3cc 100644 --- a/IAEngine.h +++ b/IAEngine.h @@ -8,8 +8,23 @@ #ifndef IAENGINE_H_ #define IAENGINE_H_ +typedef struct noeud +{ + int compteur, min, cout_f; // + + int ParentX; + int ParentY; + // 'adresse' du parent (qui sera toujours dans la map fermée) +}NOEUD; + + int FindShortestPath(int Player1PositionX, int Player1PositionY, int Player2PositionX, int Player2PositionY); //int IAEngine(PLAYER * player1, PLAYER * player2); int IAEngine(ARENA_H_TILE* arena,PLAYER * player1, PLAYER * player2); +int distance(int x1, int y1, int x2, int y2); +//int CalculatePath(ARENA_H_TILE* arena,int PositionX, int PositionY,PLAYER * player1, int compteur, int distance,int min); +//int CalculatePath(ARENA_H_TILE* arena,int posX, int posY,NOEUD * n1,PLAYER * player1, int compteur, int dist,int min); +NOEUD * CalculatePath(ARENA_H_TILE* arena,int posX, int posY,NOEUD * n1,PLAYER * player1,PLAYER * player2, int compteur, int dist,int min); +//NOEUD * CalculatePath(ARENA_H_TILE* arena,int posX, int posY,NOEUD * n1,PLAYER * player1, int compteur, int dist,int min); #endif /* IAENGINE_H_ */ diff --git a/dirt_brown.png b/Landscape/dirt_brown.png similarity index 100% rename from dirt_brown.png rename to Landscape/dirt_brown.png diff --git a/Landscape/grass_green_32x32.png b/Landscape/grass_green_32x32.png new file mode 100755 index 0000000..22b4900 Binary files /dev/null and b/Landscape/grass_green_32x32.png differ diff --git a/Landscape/river_green_32x32.png b/Landscape/river_green_32x32.png new file mode 100755 index 0000000..935c66f Binary files /dev/null and b/Landscape/river_green_32x32.png differ diff --git a/Landscape/stone_green_32x32.png b/Landscape/stone_green_32x32.png new file mode 100755 index 0000000..b5cabca Binary files /dev/null and b/Landscape/stone_green_32x32.png differ diff --git a/stone_resize.png b/Landscape/stone_resize.png similarity index 100% rename from stone_resize.png rename to Landscape/stone_resize.png diff --git a/Landscape/tree_green_32x32.png b/Landscape/tree_green_32x32.png new file mode 100755 index 0000000..1e7883f Binary files /dev/null and b/Landscape/tree_green_32x32.png differ diff --git a/tree_resize.png b/Landscape/tree_resize.png similarity index 100% rename from tree_resize.png rename to Landscape/tree_resize.png diff --git a/arenaEngine.c b/arenaEngine.c index 191c9cd..7a094d8 100644 --- a/arenaEngine.c +++ b/arenaEngine.c @@ -9,7 +9,7 @@ * Arena generate functions */ -#define BLOC_SIZE 34 // Taille d'un bloc (carré) en pixels +#define BLOC_SIZE 32 // Taille d'un bloc (carré) en pixels #define NB_BLOCS_LARGEUR 20 #define NB_BLOCS_HAUTEUR 20 #define LARGEUR_FENETRE BLOC_SIZE * NB_BLOCS_LARGEUR @@ -29,7 +29,8 @@ ARENA_H_TILE* genNewArena(int size_h, int size_w) //int i = 0, j = 0; printf("Chargement du fichier\n"); - fichier = fopen("level1-20x20.lvl", "r"); + fichier = fopen("level2-20x20.lvl", "r"); + if (fichier == NULL) return 0; diff --git a/fileHandler.c b/fileHandler.c index 5b1ec5a..6b436c3 100644 --- a/fileHandler.c +++ b/fileHandler.c @@ -15,7 +15,7 @@ #include "fileHandler.h" //#include "main.c" -#define BLOC_SIZE 34 // Taille d'un bloc (carré) en pixels +#define BLOC_SIZE 32 // Taille d'un bloc (carré) en pixels #define NB_BLOCS_LARGEUR 20 #define NB_BLOCS_HAUTEUR 20 #define LARGEUR_FENETRE BLOC_SIZE * NB_BLOCS_LARGEUR diff --git a/fileHandler.h b/fileHandler.h index a0d5d8e..d254b6d 100644 --- a/fileHandler.h +++ b/fileHandler.h @@ -8,7 +8,7 @@ #ifndef FILEHANDLER_H_ #define FILEHANDLER_H_ -#define BLOC_SIZE 34 // Taille d'un bloc (carré) en pixels +#define BLOC_SIZE 32 // Taille d'un bloc (carré) en pixels #define NB_BLOCS_LARGEUR 20 #define NB_BLOCS_HAUTEUR 20 #define LARGEUR_FENETRE BLOC_SIZE * NB_BLOCS_LARGEUR diff --git a/level2-20x20.lvl b/level2-20x20.lvl new file mode 100644 index 0000000..55cfcee --- /dev/null +++ b/level2-20x20.lvl @@ -0,0 +1 @@ +0022200002222200001000022001022200000022000200000022200000022000002200020000100222000102000000000000200000000000022200020000002220000022000000010222220000020002220000222000100000002000000000000022200000000022200000202200000200020000000220000022200000010000002200020000200000022222001000000000000022220000000220000000002222000000200000100002222201000000022200002220000220000220000200000022220000200100 diff --git a/main.c b/main.c index 57620f3..bb18807 100644 --- a/main.c +++ b/main.c @@ -15,7 +15,7 @@ #include #include -#define BLOC_SIZE 34 // Taille d'un bloc (carré) en pixels +#define BLOC_SIZE 32 // Taille d'un bloc (carré) en pixels #define NB_BLOCS_LARGEUR 20 #define NB_BLOCS_HAUTEUR 20 #define LARGEUR_FENETRE BLOC_SIZE * NB_BLOCS_LARGEUR @@ -44,7 +44,7 @@ int main(void) SDL_Surface *player[4] = {NULL}; // 4 surfaces pour 4 directions de mario SDL_Surface *IA1[4] = {NULL}; // 4 surfaces pour 4 directions de mario SDL_Surface *grass = NULL; - SDL_Surface *rock = NULL, *tree = NULL,*actualPlayer = NULL, *actualIA1 = NULL; + SDL_Surface *rock = NULL, *tree = NULL, *river = NULL,*actualPlayer = NULL, *actualIA1 = NULL; SDL_Rect position, positionJoueur; @@ -67,12 +67,20 @@ int main(void) printf("Erreur de la génération de l'arène\n"); } // Chargement des sprites (décors, personnage...) - grass = IMG_Load("/home/isen/eclipse-workspace/ArenaWarSurvival/dirt_brown.png"); - rock = IMG_Load("/home/isen/eclipse-workspace/ArenaWarSurvival/stone_resize.png"); - tree = IMG_Load("/home/isen/eclipse-workspace/ArenaWarSurvival/tree_resize.png"); + grass = IMG_Load("Landscape/grass_green_32x32.png"); + rock = IMG_Load("Landscape/stone_green_32x32.png"); + tree = IMG_Load("Landscape/tree_green_32x32.png"); + river = IMG_Load("Landscape/river_green_32x32.png"); - player[BAS] = IMG_Load("adventurer_resize.png"); - IA1[BAS] = IMG_Load("zombie_resize.png"); + player[BAS] = IMG_Load("Adventurer/adventurer1_32x32.png"); + player[HAUT] = IMG_Load("Adventurer/adventurer_back_32x32.png"); + player[DROITE] = IMG_Load("Adventurer/adventurer1_right_32x32.png"); + player[GAUCHE] = IMG_Load("Adventurer/adventurer1_left_32x32.png"); + + IA1[BAS] = IMG_Load("IA1/adventurer2_32x32.png"); + IA1[HAUT] = IMG_Load("IA1/adventurer2_back_32x32.png"); + IA1[DROITE] = IMG_Load("IA1/adventurer2_right_32x32.png"); + IA1[GAUCHE] = IMG_Load("IA1/adventurer2_left_32x32.png"); actualPlayer = player[BAS]; actualIA1 = IA1[BAS]; diff --git a/playerInterface.c b/playerInterface.c index 705d6b0..8449ccb 100644 --- a/playerInterface.c +++ b/playerInterface.c @@ -14,7 +14,7 @@ enum {GRASS, ROCK, TREE,FIRSTPLAYER, IA1}; -#define BLOC_SIZE 34 // Taille d'un bloc (carré) en pixels +#define BLOC_SIZE 32 // Taille d'un bloc (carré) en pixels #define NB_BLOCS_LARGEUR 20 #define NB_BLOCS_HAUTEUR 20 #define LARGEUR_FENETRE BLOC_SIZE * NB_BLOCS_LARGEUR diff --git a/zombie_resize.png b/zombie_resize.png deleted file mode 100755 index bb2ddde..0000000 Binary files a/zombie_resize.png and /dev/null differ