Ajout Affichage arène et gestion IA révisée
This commit is contained in:
parent
fc7085d306
commit
54e0925e35
64
IAEngine.c
64
IAEngine.c
@ -8,6 +8,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "playerInterface.h"
|
#include "playerInterface.h"
|
||||||
|
#include "arenaEngine.h"
|
||||||
|
#include "IAEngine.h"
|
||||||
|
|
||||||
#include "SDL2/SDL.h"
|
#include "SDL2/SDL.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -15,22 +18,19 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int IAEngine(PLAYER * player1, PLAYER * player2)
|
int IAEngine(ARENA_H_TILE* arena,PLAYER * player1, PLAYER * player2)
|
||||||
{
|
{
|
||||||
char Race[20];
|
//Fonction avec seulement 2 joueurs, voir la gestion quand il y a 2 IA supplémentaire
|
||||||
|
|
||||||
//Player 1 est le joueur, player 2 le bot
|
//Player 1 est le joueur, player 2 le bot
|
||||||
|
|
||||||
|
|
||||||
if((player1 != NULL) & (player2 !=NULL))
|
if((player1 != NULL) & (player2 !=NULL))
|
||||||
{
|
{
|
||||||
//On récupère les positions des 2 joueurs . L'IA sait où est le joueur
|
//On récupère les positions des 2 joueurs . L'IA sait où est le joueur
|
||||||
int Player1PositionX = player1->PositionX;
|
|
||||||
int Player1PositionY = player1->PositionY;
|
|
||||||
|
|
||||||
int Player2PositionX = player2->PositionX;
|
|
||||||
int Player2PositionY = player2->PositionY;
|
|
||||||
int action;
|
int action;
|
||||||
|
|
||||||
action = FindShortestPath(Player1PositionX,Player1PositionY,Player2PositionX,Player2PositionY);
|
action = FindShortestPath(player1->PositionX,player1->PositionY,player2->PositionX,player2->PositionY);
|
||||||
|
|
||||||
printf("Tour de l'IA\n");
|
printf("Tour de l'IA\n");
|
||||||
if(action == 5)
|
if(action == 5)
|
||||||
@ -39,40 +39,62 @@ int IAEngine(PLAYER * player1, PLAYER * player2)
|
|||||||
}
|
}
|
||||||
else if ((action >= 1) && (action <= 4))
|
else if ((action >= 1) && (action <= 4))
|
||||||
{
|
{
|
||||||
ActionPlayer(player2,action);
|
ActionPlayer(arena,player2,action);
|
||||||
|
}
|
||||||
|
//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);
|
||||||
|
if(action == 5)
|
||||||
|
{
|
||||||
|
AttackPlayer(player2,player1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//Fonction de reflexion IA fonctionne mais les pierres et arbres sont bloquants
|
||||||
|
|
||||||
int FindShortestPath(int Player1PositionX, int Player1PositionY, int Player2PositionX, int Player2PositionY)
|
int FindShortestPath(int Player1PositionX, int Player1PositionY, int Player2PositionX, int Player2PositionY)
|
||||||
{
|
{
|
||||||
|
printf("Player1PositionX : %i et Player1PositionY : %i \n",Player1PositionX,Player1PositionY);
|
||||||
|
printf("Player2PositionX : %i et Player2PositionY : %i \n",Player2PositionX,Player2PositionY);
|
||||||
int differenceX = abs(Player1PositionX - Player2PositionX);
|
int differenceX = abs(Player1PositionX - Player2PositionX);
|
||||||
int differenceY = abs(Player1PositionY - Player2PositionY);
|
int differenceY = abs(Player1PositionY - Player2PositionY);
|
||||||
|
|
||||||
int action;
|
printf("DifferenceX : %i et DifferenceY : %i \n",differenceX,differenceY);
|
||||||
|
|
||||||
|
int action=0;
|
||||||
|
|
||||||
//Revoir cette partie il faut que les 2 joueurs soit sur la même ligne ou colone avec une différence de ligne ou colonne de 1
|
/*if(((differenceX == 1) && (differenceY == 0)) || ((differenceX == 0) && (differenceY == 1)))
|
||||||
if((abs(Player1PositionX - (Player2PositionX - 1)) == 1) ||
|
|
||||||
(abs(Player1PositionX - (Player2PositionX + 1)) == 1) ||
|
|
||||||
(abs(Player1PositionX - (Player2PositionY - 1)) == 1) ||
|
|
||||||
(abs(Player1PositionX - (Player2PositionY + 1)) == 1))
|
|
||||||
{
|
{
|
||||||
printf("Les 2 joueur sont à coté\n");
|
printf("Les 2 joueur sont à coté\n");
|
||||||
printf("Le joueur 2 va combattre\n");
|
printf("Le joueur 2 va combattre\n");
|
||||||
action = 5;
|
action = 5;
|
||||||
|
return action;
|
||||||
|
}*/
|
||||||
|
if(((differenceX == 1) && (differenceY == 0)) || ((differenceX == 0) && (differenceY == 1)))
|
||||||
|
{
|
||||||
|
printf("Attack en cours\n");
|
||||||
|
return action = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(differenceX > abs(Player1PositionX - (Player2PositionX - 1)))
|
else if(differenceX > abs(Player1PositionX - (Player2PositionX - 1)))
|
||||||
|
//if(differenceX > abs(Player1PositionX - (Player2PositionX - 1)))
|
||||||
{
|
{
|
||||||
printf("Chemin plus court sur X\n");
|
printf("Chemin plus court sur X gauche\n");
|
||||||
printf("Le joueur 2 va vers la gauche\n");
|
printf("Le joueur 2 va vers la gauche\n");
|
||||||
action = 4;
|
action = 4;
|
||||||
}
|
}
|
||||||
else if(differenceX > abs(Player1PositionX - (Player2PositionX + 1)))
|
else if(differenceX > abs(Player1PositionX - (Player2PositionX + 1)))
|
||||||
{
|
{
|
||||||
printf("Chemin plus court sur X\n");
|
printf("Chemin plus court sur X droite\n");
|
||||||
printf("Le joueur 2 va vers la droite\n");
|
printf("Le joueur 2 va vers la droite\n");
|
||||||
action = 2;
|
action = 2;
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#define IAENGINE_H_
|
#define IAENGINE_H_
|
||||||
|
|
||||||
int FindShortestPath(int Player1PositionX, int Player1PositionY, int Player2PositionX, int Player2PositionY);
|
int FindShortestPath(int Player1PositionX, int Player1PositionY, int Player2PositionX, int Player2PositionY);
|
||||||
int IAEngine(PLAYER * player1, PLAYER * player2);
|
//int IAEngine(PLAYER * player1, PLAYER * player2);
|
||||||
|
int IAEngine(ARENA_H_TILE* arena,PLAYER * player1, PLAYER * player2);
|
||||||
|
|
||||||
#endif /* IAENGINE_H_ */
|
#endif /* IAENGINE_H_ */
|
||||||
|
BIN
adventurer_resize.png
Executable file
BIN
adventurer_resize.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
225
arenaEngine.c
225
arenaEngine.c
@ -2,75 +2,75 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "fileHandler.h"
|
#include "fileHandler.h"
|
||||||
#include "logHelper.h"
|
//#include "logHelper.h"
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Arena generate functions
|
* Arena generate functions
|
||||||
*/
|
*/
|
||||||
ARENA_H_TILE* createHTile(ARENA_H_TILE* prevHTile) {
|
|
||||||
ARENA_H_TILE* tile_h = NULL;
|
|
||||||
|
|
||||||
if (prevHTile == NULL) {
|
#define BLOC_SIZE 34 // Taille d'un bloc (carré) en pixels
|
||||||
tile_h = calloc(1,sizeof(ARENA_H_TILE)); //Using calloc because of resetting all memory allocated to 0
|
#define NB_BLOCS_LARGEUR 20
|
||||||
tile_h->type_id = 0;
|
#define NB_BLOCS_HAUTEUR 20
|
||||||
tile_h->playerOnTile = NULL;
|
#define LARGEUR_FENETRE BLOC_SIZE * NB_BLOCS_LARGEUR
|
||||||
tile_h->nextRow = NULL;
|
#define HAUTEUR_FENETRE BLOC_SIZE * NB_BLOCS_HAUTEUR
|
||||||
tile_h->nextColumn = NULL;
|
|
||||||
} else if (prevHTile != NULL) {
|
|
||||||
tile_h = calloc(1,sizeof(ARENA_H_TILE));
|
|
||||||
prevHTile->nextRow = tile_h;
|
|
||||||
tile_h->type_id = 0;
|
|
||||||
tile_h->playerOnTile = NULL;
|
|
||||||
tile_h->nextRow = NULL;
|
|
||||||
tile_h->nextColumn = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return tile_h;
|
|
||||||
}
|
|
||||||
|
|
||||||
ARENA_W_TILE* createWTile(ARENA_H_TILE* prevHTile, ARENA_W_TILE* prevWTile) {
|
|
||||||
ARENA_W_TILE* tile_w = NULL;
|
|
||||||
|
|
||||||
if (prevHTile != NULL && prevWTile == NULL) {
|
ARENA_H_TILE* genNewArena(int size_h, int size_w)
|
||||||
tile_w = calloc(1,sizeof(ARENA_W_TILE));
|
{
|
||||||
prevHTile->nextColumn = tile_w;
|
|
||||||
tile_w->type_id = 0;
|
|
||||||
tile_w->playerOnTile = NULL;
|
|
||||||
tile_w->nextColumn = NULL;
|
|
||||||
|
|
||||||
return tile_w;
|
|
||||||
} else if (prevHTile == NULL && prevWTile != NULL) {
|
|
||||||
tile_w = calloc(1,sizeof(ARENA_W_TILE));
|
|
||||||
prevWTile->nextColumn = tile_w;
|
|
||||||
tile_w->type_id = 0;
|
|
||||||
tile_w->playerOnTile = NULL;
|
|
||||||
tile_w->nextColumn = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ARENA_H_TILE* genNewArena(int size_h, int size_w) {
|
|
||||||
ARENA_H_TILE* arenaOrigin = NULL;
|
ARENA_H_TILE* arenaOrigin = NULL;
|
||||||
ARENA_H_TILE* TmpCursor_h = NULL;
|
ARENA_H_TILE* TmpCursor_h = NULL;
|
||||||
ARENA_W_TILE* TmpCursor_w = NULL;
|
ARENA_W_TILE* TmpCursor_w = NULL;
|
||||||
int i,j;
|
int i,j;
|
||||||
|
|
||||||
for(i=0;i<size_h;i++){
|
FILE* fichier = NULL;
|
||||||
if (i==0) {
|
char ligneFichier[NB_BLOCS_LARGEUR * NB_BLOCS_HAUTEUR + 1] = {0};
|
||||||
|
//int i = 0, j = 0;
|
||||||
|
|
||||||
|
printf("Chargement du fichier\n");
|
||||||
|
fichier = fopen("level1-20x20.lvl", "r");
|
||||||
|
if (fichier == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
fgets(ligneFichier, size_w * size_h + 1, fichier);
|
||||||
|
|
||||||
|
for(i=0;i<size_h;i++)
|
||||||
|
{
|
||||||
|
if (i==0)
|
||||||
|
{
|
||||||
arenaOrigin = createHTile(NULL);
|
arenaOrigin = createHTile(NULL);
|
||||||
TmpCursor_h = arenaOrigin;
|
TmpCursor_h = arenaOrigin;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
TmpCursor_h = createHTile(TmpCursor_h);
|
TmpCursor_h = createHTile(TmpCursor_h);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(j=0;j<size_w;j++){
|
for(j=0;j<size_w;j++)
|
||||||
if (j==0) {
|
{
|
||||||
|
if (j==0)
|
||||||
|
{
|
||||||
TmpCursor_w = createWTile(TmpCursor_h, NULL);
|
TmpCursor_w = createWTile(TmpCursor_h, NULL);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
createWTile(NULL, TmpCursor_w);
|
createWTile(NULL, TmpCursor_w);
|
||||||
}
|
}
|
||||||
|
switch (ligneFichier[(i * size_w) + j])
|
||||||
|
{
|
||||||
|
case '0': TmpCursor_w->type_id = 0;
|
||||||
|
//printf("herbe\n");
|
||||||
|
break;
|
||||||
|
case '1':
|
||||||
|
TmpCursor_w->type_id = 1;
|
||||||
|
// printf("caillou\n");
|
||||||
|
break;
|
||||||
|
case '2':
|
||||||
|
TmpCursor_w->type_id = 2;
|
||||||
|
//printf("arbre\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (j!=0) TmpCursor_w = TmpCursor_w->nextColumn;
|
if (j!=0) TmpCursor_w = TmpCursor_w->nextColumn;
|
||||||
}
|
}
|
||||||
@ -81,10 +81,102 @@ ARENA_H_TILE* genNewArena(int size_h, int size_w) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ARENA_H_TILE* createHTile(ARENA_H_TILE* prevHTile)
|
||||||
|
{
|
||||||
|
ARENA_H_TILE* tile_h = NULL;
|
||||||
|
|
||||||
|
if (prevHTile == NULL)
|
||||||
|
{
|
||||||
|
tile_h = calloc(1,sizeof(ARENA_H_TILE)); //Using calloc because of resetting all memory allocated to 0
|
||||||
|
tile_h->type_id = 0;
|
||||||
|
//tile_h->playerOnTile = NULL;
|
||||||
|
tile_h->nextRow = NULL;
|
||||||
|
tile_h->nextColumn = NULL;
|
||||||
|
}
|
||||||
|
else if (prevHTile != NULL)
|
||||||
|
{
|
||||||
|
tile_h = calloc(1,sizeof(ARENA_H_TILE));
|
||||||
|
prevHTile->nextRow = tile_h;
|
||||||
|
tile_h->type_id = 0;
|
||||||
|
//tile_h->playerOnTile = NULL;
|
||||||
|
tile_h->nextRow = NULL;
|
||||||
|
tile_h->nextColumn = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return tile_h;
|
||||||
|
}
|
||||||
|
|
||||||
|
ARENA_W_TILE* createWTile(ARENA_H_TILE* prevHTile, ARENA_W_TILE* prevWTile)
|
||||||
|
{
|
||||||
|
ARENA_W_TILE* tile_w = NULL;
|
||||||
|
|
||||||
|
if (prevHTile != NULL && prevWTile == NULL)
|
||||||
|
{
|
||||||
|
tile_w = calloc(1,sizeof(ARENA_W_TILE));
|
||||||
|
prevHTile->nextColumn = tile_w;
|
||||||
|
tile_w->type_id = 0;
|
||||||
|
//tile_w->playerOnTile = NULL;
|
||||||
|
tile_w->nextColumn = NULL;
|
||||||
|
|
||||||
|
return tile_w;
|
||||||
|
}
|
||||||
|
else if (prevHTile == NULL && prevWTile != NULL)
|
||||||
|
{
|
||||||
|
tile_w = calloc(1,sizeof(ARENA_W_TILE));
|
||||||
|
prevWTile->nextColumn = tile_w;
|
||||||
|
tile_w->type_id = 0;
|
||||||
|
//tile_w->playerOnTile = NULL;
|
||||||
|
tile_w->nextColumn = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
ARENA_H_TILE* genNewArena(int size_h, int size_w)
|
||||||
|
{
|
||||||
|
ARENA_H_TILE* arenaOrigin = NULL;
|
||||||
|
ARENA_H_TILE* TmpCursor_h = NULL;
|
||||||
|
ARENA_W_TILE* TmpCursor_w = NULL;
|
||||||
|
int i,j;
|
||||||
|
|
||||||
|
for(i=0;i<size_h;i++)
|
||||||
|
{
|
||||||
|
if (i==0)
|
||||||
|
{
|
||||||
|
arenaOrigin = createHTile(NULL);
|
||||||
|
TmpCursor_h = arenaOrigin;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TmpCursor_h = createHTile(TmpCursor_h);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(j=0;j<size_w;j++)
|
||||||
|
{
|
||||||
|
if (j==0)
|
||||||
|
{
|
||||||
|
TmpCursor_w = createWTile(TmpCursor_h, NULL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
createWTile(NULL, TmpCursor_w);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (j!=0) TmpCursor_w = TmpCursor_w->nextColumn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return arenaOrigin;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Arena delete functions
|
* Arena delete functions
|
||||||
*/
|
*/
|
||||||
void deleteWTile(ARENA_W_TILE* WTile) {
|
void deleteWTile(ARENA_W_TILE* WTile)
|
||||||
|
{
|
||||||
if (WTile->nextColumn != NULL) {
|
if (WTile->nextColumn != NULL) {
|
||||||
deleteWTile(WTile->nextColumn);
|
deleteWTile(WTile->nextColumn);
|
||||||
}
|
}
|
||||||
@ -92,8 +184,10 @@ void deleteWTile(ARENA_W_TILE* WTile) {
|
|||||||
free(WTile);
|
free(WTile);
|
||||||
}
|
}
|
||||||
|
|
||||||
void deleteHTile(ARENA_H_TILE* HTile) {
|
void deleteHTile(ARENA_H_TILE* HTile)
|
||||||
if (HTile->nextRow != NULL) {
|
{
|
||||||
|
if (HTile->nextRow != NULL)
|
||||||
|
{
|
||||||
deleteHTile(HTile->nextRow);
|
deleteHTile(HTile->nextRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,7 +195,8 @@ void deleteHTile(ARENA_H_TILE* HTile) {
|
|||||||
free(HTile);
|
free(HTile);
|
||||||
}
|
}
|
||||||
|
|
||||||
void deleteArena(ARENA_H_TILE* arena) {
|
void deleteArena(ARENA_H_TILE* arena)
|
||||||
|
{
|
||||||
deleteHTile(arena);
|
deleteHTile(arena);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,35 +205,45 @@ void deleteArena(ARENA_H_TILE* arena) {
|
|||||||
/*
|
/*
|
||||||
* Arena status functions
|
* Arena status functions
|
||||||
*/
|
*/
|
||||||
int getTileTypeID(ARENA_H_TILE* arena, int coord_x, int coord_y) {
|
int getTileTypeID(ARENA_H_TILE* arena, int coord_x, int coord_y)
|
||||||
|
{
|
||||||
int type_id = -1;
|
int type_id = -1;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (coord_y == 0) {
|
if (coord_y == 0)
|
||||||
|
{
|
||||||
ARENA_H_TILE* tile_h = NULL;
|
ARENA_H_TILE* tile_h = NULL;
|
||||||
|
|
||||||
tile_h = arena;
|
tile_h = arena;
|
||||||
if (coord_x != 0) {
|
if (coord_x != 0)
|
||||||
for (i=0;i<coord_x;i++) {
|
{
|
||||||
|
for (i=0;i<coord_x;i++)
|
||||||
|
{
|
||||||
tile_h = arena->nextRow;
|
tile_h = arena->nextRow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type_id = tile_h->type_id;
|
type_id = tile_h->type_id;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
ARENA_W_TILE* tile_w = NULL;
|
ARENA_W_TILE* tile_w = NULL;
|
||||||
ARENA_H_TILE* tile_h = NULL;
|
ARENA_H_TILE* tile_h = NULL;
|
||||||
|
|
||||||
tile_h = arena;
|
tile_h = arena;
|
||||||
if (coord_x != 0) {
|
if (coord_x != 0)
|
||||||
for (i=0;i<coord_x;i++) {
|
{
|
||||||
|
for (i=0;i<coord_x;i++)
|
||||||
|
{
|
||||||
tile_h = tile_h->nextRow;
|
tile_h = tile_h->nextRow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tile_w = tile_h->nextColumn;
|
tile_w = tile_h->nextColumn;
|
||||||
if (coord_y != 0) {
|
if (coord_y != 0)
|
||||||
for (i=0;i<coord_y;i++) {
|
{
|
||||||
|
for (i=0;i<coord_y;i++)
|
||||||
|
{
|
||||||
tile_w = tile_w->nextColumn;
|
tile_w = tile_w->nextColumn;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "playerInterface.h"
|
//#include "playerInterface.h"
|
||||||
|
|
||||||
#ifndef ARENAENGINE_H_
|
#ifndef ARENAENGINE_H_
|
||||||
#define ARENAENGINE_H_
|
#define ARENAENGINE_H_
|
||||||
@ -15,23 +15,26 @@ typedef struct items{
|
|||||||
}ITEMS;
|
}ITEMS;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct tileType{
|
typedef struct tileType
|
||||||
|
{
|
||||||
int type_id;
|
int type_id;
|
||||||
//texture?
|
//texture?
|
||||||
int isGround;
|
int isGround;
|
||||||
int canBeMined;
|
int canBeMined;
|
||||||
}TILE;
|
}TILE;
|
||||||
|
|
||||||
typedef struct arena_h_tile{ //Rows chained list
|
typedef struct arena_h_tile
|
||||||
|
{ //Rows chained list
|
||||||
int type_id;
|
int type_id;
|
||||||
PLAYER* playerOnTile;
|
//PLAYER* playerOnTile;
|
||||||
struct arena_h_tile *nextRow;
|
struct arena_h_tile *nextRow;
|
||||||
struct arena_w_tile *nextColumn;
|
struct arena_w_tile *nextColumn;
|
||||||
}ARENA_H_TILE;
|
}ARENA_H_TILE;
|
||||||
|
|
||||||
typedef struct arena_w_tile{ //Columns chained list
|
typedef struct arena_w_tile
|
||||||
|
{ //Columns chained list
|
||||||
int type_id;
|
int type_id;
|
||||||
PLAYER* playerOnTile;
|
//PLAYER* playerOnTile;
|
||||||
struct arena_w_tile *nextColumn;
|
struct arena_w_tile *nextColumn;
|
||||||
}ARENA_W_TILE;
|
}ARENA_W_TILE;
|
||||||
|
|
||||||
@ -40,6 +43,9 @@ typedef struct arena_w_tile{ //Columns chained list
|
|||||||
ARENA_H_TILE* genNewArena(int size_h, int size_w);
|
ARENA_H_TILE* genNewArena(int size_h, int size_w);
|
||||||
void deleteArena(ARENA_H_TILE* arena);
|
void deleteArena(ARENA_H_TILE* arena);
|
||||||
|
|
||||||
|
ARENA_H_TILE* createHTile(ARENA_H_TILE* prevHTile);
|
||||||
|
ARENA_W_TILE* createWTile(ARENA_H_TILE* prevHTile, ARENA_W_TILE* prevWTile);
|
||||||
|
|
||||||
//Status functions
|
//Status functions
|
||||||
int getTileTypeID(ARENA_H_TILE* arena, int coord_x, int coord_y);
|
int getTileTypeID(ARENA_H_TILE* arena, int coord_x, int coord_y);
|
||||||
|
|
||||||
|
BIN
dirt_brown.png
Executable file
BIN
dirt_brown.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 246 B |
121
fileHandler.c
121
fileHandler.c
@ -1,15 +1,118 @@
|
|||||||
#include <stdio.h>
|
/*
|
||||||
|
* fileHandler.c
|
||||||
|
*
|
||||||
|
* Created on: 20 juin 2018
|
||||||
|
* Author: isen
|
||||||
|
*
|
||||||
|
* Contient la gestion des fichier et notament la récupération d'un niveau
|
||||||
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <stdio.h>
|
||||||
|
#include "SDL2/SDL.h"
|
||||||
|
#include "SDL2/SDL_image.h"
|
||||||
|
|
||||||
int resOpen(char* filename, FILE* f) {
|
#include "fileHandler.h"
|
||||||
char fLoc[128];
|
//#include "main.c"
|
||||||
|
|
||||||
strcpy(fLoc, "resources/");
|
#define BLOC_SIZE 34 // Taille d'un bloc (carré) en pixels
|
||||||
strcat(fLoc, filename);
|
#define NB_BLOCS_LARGEUR 20
|
||||||
f = fopen(fLoc, "rb");
|
#define NB_BLOCS_HAUTEUR 20
|
||||||
|
#define LARGEUR_FENETRE BLOC_SIZE * NB_BLOCS_LARGEUR
|
||||||
|
#define HAUTEUR_FENETRE BLOC_SIZE * NB_BLOCS_HAUTEUR
|
||||||
|
/*
|
||||||
|
|
||||||
if (f != NULL) return 0;
|
PLAYER * LoadLevel(ARENA_H_TILE *Head)
|
||||||
|
{
|
||||||
|
printf("Fonction Chargement d'un niveau\n");
|
||||||
|
|
||||||
return -1;
|
if(Head == NULL)
|
||||||
|
{
|
||||||
|
printf("La liste est vide\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FILE* fichier = NULL;
|
||||||
|
char ligneFichier[NB_BLOCS_LARGEUR * NB_BLOCS_HAUTEUR + 1] = {0};
|
||||||
|
int i = 0, j = 0;
|
||||||
|
|
||||||
|
//Ouverture du fichier
|
||||||
|
fichier = fopen("level1.lvl", "r");
|
||||||
|
if (fichier == NULL)
|
||||||
|
return 0;
|
||||||
|
//Lecture du fichier
|
||||||
|
fgets(ligneFichier, NB_BLOCS_LARGEUR * NB_BLOCS_HAUTEUR + 1, fichier);
|
||||||
|
|
||||||
|
for (i = 0 ; i < NB_BLOCS_LARGEUR ; i++)
|
||||||
|
{
|
||||||
|
for (j = 0 ; j < NB_BLOCS_HAUTEUR ; j++)
|
||||||
|
{
|
||||||
|
switch (ligneFichier[(i * NB_BLOCS_LARGEUR) + j])
|
||||||
|
{
|
||||||
|
case '0':
|
||||||
|
//Herbe
|
||||||
|
ARENA_H_TILE->Type = 0;
|
||||||
|
break;
|
||||||
|
case '1':
|
||||||
|
//Pierre
|
||||||
|
ARENA_H_TILE->Type = 1;
|
||||||
|
break;
|
||||||
|
case '2':
|
||||||
|
//Arbre
|
||||||
|
ARENA_H_TILE->Type = 2;
|
||||||
|
break;
|
||||||
|
case '3':
|
||||||
|
//Rivière
|
||||||
|
ARENA_H_TILE->Type = 3;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Head = Head->suiv;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
//Fonction a réadapter avec la liste chainée Arene
|
||||||
|
|
||||||
|
int chargerNiveau(int niveau[][NB_BLOCS_HAUTEUR])
|
||||||
|
{
|
||||||
|
FILE* fichier = NULL;
|
||||||
|
char ligneFichier[NB_BLOCS_LARGEUR * NB_BLOCS_HAUTEUR + 1] = {0};
|
||||||
|
int i = 0, j = 0;
|
||||||
|
|
||||||
|
printf("Chargement du fichier\n");
|
||||||
|
fichier = fopen("level1.lvl", "r");
|
||||||
|
if (fichier == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
fgets(ligneFichier, NB_BLOCS_LARGEUR * NB_BLOCS_HAUTEUR + 1, fichier);
|
||||||
|
|
||||||
|
for (i = 0 ; i < NB_BLOCS_LARGEUR ; i++)
|
||||||
|
{
|
||||||
|
for (j = 0 ; j < NB_BLOCS_HAUTEUR ; j++)
|
||||||
|
{
|
||||||
|
//printf("j= %i \n",j);
|
||||||
|
switch (ligneFichier[(i * NB_BLOCS_LARGEUR) + j])
|
||||||
|
{
|
||||||
|
case '0':
|
||||||
|
niveau[j][i] = 0;
|
||||||
|
//printf("herbe\n");
|
||||||
|
break;
|
||||||
|
case '1':
|
||||||
|
niveau[j][i] = 1;
|
||||||
|
// printf("caillou\n");
|
||||||
|
break;
|
||||||
|
case '2':
|
||||||
|
niveau[j][i] = 2;
|
||||||
|
//printf("arbre\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//printf("Ligne\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(fichier);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* fileHandler.h
|
||||||
|
*
|
||||||
|
* Created on: 20 juin 2018
|
||||||
|
* Author: isen
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef FILEHANDLER_H_
|
#ifndef FILEHANDLER_H_
|
||||||
#define FILEHANDLER_H_
|
#define FILEHANDLER_H_
|
||||||
|
|
||||||
int resOpen(char* filename);
|
#define BLOC_SIZE 34 // 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
|
||||||
|
#define HAUTEUR_FENETRE BLOC_SIZE * NB_BLOCS_HAUTEUR
|
||||||
|
|
||||||
#endif
|
int chargerNiveau(int niveau[][NB_BLOCS_HAUTEUR]);
|
||||||
|
|
||||||
|
#endif /* FILEHANDLER_H_ */
|
||||||
|
1
level1-20x20.lvl
Normal file
1
level1-20x20.lvl
Normal file
@ -0,0 +1 @@
|
|||||||
|
00000000000000000000000010000220000010000000000022000000000210000022200000000022000002220000100000020000000220000000000000000000000000000000000000000000000000000000100002200000100022000022222000000000000000002200000000021000002220000000002200000222000010000002000000022000000000000000100002200000100022000022222000000000000000002200000000020000000220000000000000000000000000000000
|
218
main.c
218
main.c
@ -7,54 +7,206 @@
|
|||||||
|
|
||||||
//#include "IAEngine.h"
|
//#include "IAEngine.h"
|
||||||
#include "playerInterface.h"
|
#include "playerInterface.h"
|
||||||
#include "SDL2/SDL.h"
|
#include "fileHandler.h"
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include "logHelper.h"
|
|
||||||
#include <SDL2/SDL.h>
|
|
||||||
#include <SDL2/SDL_thread.h>
|
|
||||||
#include <SDL2/SDL_mutex.h>
|
|
||||||
#include "arenaEngine.h"
|
#include "arenaEngine.h"
|
||||||
|
|
||||||
#define A_HEIGHT 100
|
#include "SDL2/SDL.h"
|
||||||
#define A_WIDTH 100
|
#include "SDL2/SDL_image.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
void initDisplayLib() {
|
#define BLOC_SIZE 34 // Taille d'un bloc (carré) en pixels
|
||||||
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
|
#define NB_BLOCS_LARGEUR 20
|
||||||
addLogCritical("Init SDL libs failed !");
|
#define NB_BLOCS_HAUTEUR 20
|
||||||
|
#define LARGEUR_FENETRE BLOC_SIZE * NB_BLOCS_LARGEUR
|
||||||
|
#define HAUTEUR_FENETRE BLOC_SIZE * NB_BLOCS_HAUTEUR
|
||||||
|
|
||||||
exit(EXIT_FAILURE);
|
enum {HAUT, BAS, GAUCHE, DROITE};
|
||||||
|
enum {GRASS, ROCK, TREE,FIRSTPLAYER, IA1}; //Définit quel type de case il s'agit
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
SDL_Init(SDL_INIT_VIDEO);
|
||||||
|
|
||||||
|
if (SDL_Init(SDL_INIT_VIDEO) != 0 )
|
||||||
|
{
|
||||||
|
fprintf(stdout,"Échec de l'initialisation de la SDL (%s)\n",SDL_GetError());
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
{
|
||||||
|
int continuer = 1;
|
||||||
|
int action;
|
||||||
|
|
||||||
void initResources() {
|
ARENA_H_TILE* arena = NULL; //Déclaration de l'arène
|
||||||
//resOpen();
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
SDL_Surface *player[4] = {NULL}; // 4 surfaces pour 4 directions de mario
|
||||||
ARENA_H_TILE* arena = NULL;
|
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_Rect position, positionJoueur;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int i = 0, j = 0;
|
||||||
|
int carte[NB_BLOCS_LARGEUR][NB_BLOCS_HAUTEUR] = {0};
|
||||||
|
|
||||||
|
//SDL_WM_SetIcon(IMG_Load("adventurer_resize.png"),NULL); //Définit l'icone de la fenêtre
|
||||||
|
|
||||||
// Création de la fenêtre
|
// Création de la fenêtre
|
||||||
SDL_Window* pWindow = NULL;
|
SDL_Window* pWindow = NULL;
|
||||||
pWindow = SDL_CreateWindow("Arena Survival Tournament",SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,640,480,SDL_WINDOW_SHOWN);
|
pWindow = SDL_CreateWindow("Arena Survival Tournament",SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,LARGEUR_FENETRE,HAUTEUR_FENETRE,SDL_WINDOW_SHOWN);
|
||||||
|
|
||||||
addLogInfo("Starting game...");
|
//Génération de la nouvelle arène à partir du fichier
|
||||||
initDisplayLib();
|
arena = genNewArena(NB_BLOCS_HAUTEUR, NB_BLOCS_LARGEUR);
|
||||||
initResources();
|
|
||||||
|
|
||||||
addLogInfo("Creating new arena...");
|
if (arena == NULL)
|
||||||
arena = genNewArena(A_HEIGHT, A_WIDTH);
|
{
|
||||||
if (arena == NULL) {
|
printf("Erreur de la génération de l'arène\n");
|
||||||
addLogCritical("Error with arena generator !");
|
}
|
||||||
exit(EXIT_FAILURE);
|
// Chargement des sprites (décors, personnage...)
|
||||||
}
|
grass = IMG_Load("/home/isen/eclipse-workspace/ArenaWarSurvival/dirt_brown.png");
|
||||||
addLogInfo("Successfully created arena.");
|
rock = IMG_Load("/home/isen/eclipse-workspace/ArenaWarSurvival/stone_resize.png");
|
||||||
|
tree = IMG_Load("/home/isen/eclipse-workspace/ArenaWarSurvival/tree_resize.png");
|
||||||
|
|
||||||
deleteArena(arena);
|
player[BAS] = IMG_Load("adventurer_resize.png");
|
||||||
addLogInfo("Cleared arena.");
|
IA1[BAS] = IMG_Load("zombie_resize.png");
|
||||||
|
|
||||||
|
actualPlayer = player[BAS];
|
||||||
|
actualIA1 = IA1[BAS];
|
||||||
|
|
||||||
|
SDL_Surface* Sprites[5]= {grass,rock,tree,actualPlayer,actualIA1};
|
||||||
|
|
||||||
|
// Chargement du niveau pour le tableau (Phase de test)
|
||||||
|
/*if (!chargerNiveau(carte))
|
||||||
|
{
|
||||||
|
printf("Niveau non chargé\n");// On arrête le jeu si on n'a pas pu charger le niveau
|
||||||
|
}*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
//Cette fonction peut être utile pour rechercher un joueur ( Pour la detection)
|
||||||
|
// Recherche de la position de Mario au départ
|
||||||
|
for (i = 0 ; i < NB_BLOCS_LARGEUR ; i++)
|
||||||
|
{
|
||||||
|
for (j = 0 ; j < NB_BLOCS_HAUTEUR ; j++)
|
||||||
|
{
|
||||||
|
if (carte[i][j] == MARIO) // Si Mario se trouve à cette position
|
||||||
|
{
|
||||||
|
positionJoueur.x = i;
|
||||||
|
positionJoueur.y = j;
|
||||||
|
carte[i][j] = VIDE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Placement des objets à l'écran à la création de l'arène
|
||||||
|
drawArena(pWindow,arena,Sprites);
|
||||||
|
|
||||||
|
|
||||||
|
SDL_Event event; // Cette variable servira plus tard à gérer les événements
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
if( pWindow )
|
||||||
|
{
|
||||||
|
SDL_UpdateWindowSurface(pWindow); //Rafaichis la fenetre
|
||||||
|
|
||||||
|
//SDL_Delay(3000); /* Attendre trois secondes, que l'utilisateur voie la fenêtre */
|
||||||
|
while (continuer)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
action = PlayerInterface(pWindow,arena,Sprites);
|
||||||
|
|
||||||
|
if (action == -1)
|
||||||
|
{
|
||||||
|
continuer = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
//SDL_DestroyWindow(pWindow);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr,"Erreur de création de la fenêtre: %s\n",SDL_GetError());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//IAEngine();
|
||||||
|
|
||||||
|
SDL_Quit();
|
||||||
|
//PlayerInterface();
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int drawArena(SDL_Window* pWindow,ARENA_H_TILE* arena,SDL_Surface **Sprites)
|
||||||
|
{
|
||||||
|
SDL_Rect position;
|
||||||
|
int ID;
|
||||||
|
for (int i = 0 ; i < NB_BLOCS_LARGEUR ; i++)
|
||||||
|
{
|
||||||
|
for (int j = 0 ; j < NB_BLOCS_HAUTEUR ; j++)
|
||||||
|
{
|
||||||
|
position.x = i * BLOC_SIZE;
|
||||||
|
position.y = j * BLOC_SIZE;
|
||||||
|
|
||||||
|
ID = getTileTypeID( arena, i, j);
|
||||||
|
switch(ID)
|
||||||
|
{
|
||||||
|
case GRASS:
|
||||||
|
SDL_BlitSurface(Sprites[GRASS], NULL, SDL_GetWindowSurface(pWindow), &position);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case ROCK:
|
||||||
|
SDL_BlitSurface(Sprites[ROCK], NULL, SDL_GetWindowSurface(pWindow), &position);
|
||||||
|
break;
|
||||||
|
case TREE:
|
||||||
|
SDL_BlitSurface(Sprites[TREE], NULL, SDL_GetWindowSurface(pWindow), &position);
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*//Fonction draw avec un tableau. A servi de test pour le graphique
|
||||||
|
int drawArena(SDL_Window* pWindow,int carte[NB_BLOCS_LARGEUR][NB_BLOCS_HAUTEUR],SDL_Surface **Sprites)
|
||||||
|
{
|
||||||
|
SDL_Rect position;
|
||||||
|
for (int i = 0 ; i < NB_BLOCS_LARGEUR ; i++)
|
||||||
|
{
|
||||||
|
for (int j = 0 ; j < NB_BLOCS_HAUTEUR ; j++)
|
||||||
|
{
|
||||||
|
position.x = i * BLOC_SIZE;
|
||||||
|
position.y = j * BLOC_SIZE;
|
||||||
|
|
||||||
|
|
||||||
|
switch(carte[i][j])
|
||||||
|
{
|
||||||
|
case GRASS:
|
||||||
|
SDL_BlitSurface(Sprites[GRASS], NULL, SDL_GetWindowSurface(pWindow), &position);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case ROCK:
|
||||||
|
SDL_BlitSurface(Sprites[ROCK], NULL, SDL_GetWindowSurface(pWindow), &position);
|
||||||
|
break;
|
||||||
|
case TREE:
|
||||||
|
SDL_BlitSurface(Sprites[TREE], NULL, SDL_GetWindowSurface(pWindow), &position);
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,17 +6,31 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "playerInterface.h"
|
#include "playerInterface.h"
|
||||||
|
//#include "arenaEngine.h"
|
||||||
|
|
||||||
#include "SDL2/SDL.h"
|
#include "SDL2/SDL.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
#define ArenaMAX 100
|
enum {GRASS, ROCK, TREE,FIRSTPLAYER, IA1};
|
||||||
|
#define BLOC_SIZE 34 // 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
|
||||||
|
#define HAUTEUR_FENETRE BLOC_SIZE * NB_BLOCS_HAUTEUR
|
||||||
|
|
||||||
int PlayerInterface(void)
|
|
||||||
|
int PlayerInterface(SDL_Window* pWindow,ARENA_H_TILE* arena,SDL_Surface **Sprites)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
//Ajouté
|
||||||
|
SDL_Rect position;
|
||||||
|
SDL_Rect oldposition;
|
||||||
|
SDL_Rect IAposition;
|
||||||
|
SDL_Rect oldIAposition;
|
||||||
|
|
||||||
|
|
||||||
PLAYER* List=NULL;
|
PLAYER* List=NULL;
|
||||||
PLAYER* Element=NULL;
|
PLAYER* Element=NULL;
|
||||||
int id=0;
|
int id=0;
|
||||||
@ -41,31 +55,49 @@ int PlayerInterface(void)
|
|||||||
printf("Nom player 2 : %s\n",player2->Name);
|
printf("Nom player 2 : %s\n",player2->Name);
|
||||||
|
|
||||||
numberAlive = NumberPlayerAlive(List);
|
numberAlive = NumberPlayerAlive(List);
|
||||||
printf("Nombre de joueur en vie : %i",numberAlive);
|
printf("Nombre de joueur en vie : %i\n",numberAlive);
|
||||||
|
|
||||||
|
int action=0;
|
||||||
int action;
|
|
||||||
|
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
action=getEvent();
|
|
||||||
|
|
||||||
if(action == 1)
|
oldposition.x = player1->PositionX * BLOC_SIZE;
|
||||||
|
oldposition.y = player1->PositionY * BLOC_SIZE;
|
||||||
|
oldIAposition.x = player2->PositionX * BLOC_SIZE;
|
||||||
|
oldIAposition.y = player2->PositionY * BLOC_SIZE;
|
||||||
|
|
||||||
|
//Affichage des joueurs au début de la partie
|
||||||
|
SDL_BlitSurface(Sprites[FIRSTPLAYER], NULL, SDL_GetWindowSurface(pWindow), &oldposition);
|
||||||
|
SDL_BlitSurface(Sprites[IA1], NULL, SDL_GetWindowSurface(pWindow), &oldIAposition);
|
||||||
|
|
||||||
|
SDL_UpdateWindowSurface(pWindow);
|
||||||
|
|
||||||
|
while(action == 0)
|
||||||
{
|
{
|
||||||
ActionPlayer(player1,1); //Déplacement vers le haut
|
action=getEvent();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(action == -1)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else if(action == 1)
|
||||||
|
{
|
||||||
|
ActionPlayer(arena,player1,1); //Déplacement vers le haut
|
||||||
}
|
}
|
||||||
else if(action == 2)
|
else if(action == 2)
|
||||||
{
|
{
|
||||||
ActionPlayer(player1,2); //Déplacement vers la droite
|
ActionPlayer(arena,player1,2); //Déplacement vers la droite
|
||||||
}
|
}
|
||||||
else if(action == 3)
|
else if(action == 3)
|
||||||
{
|
{
|
||||||
ActionPlayer(player1,3); //Déplacement vers le bas
|
ActionPlayer(arena,player1,3); //Déplacement vers le bas
|
||||||
}
|
}
|
||||||
else if(action == 4)
|
else if(action == 4)
|
||||||
{
|
{
|
||||||
ActionPlayer(player1,4); //Déplacement vers la gauche
|
ActionPlayer(arena,player1,4); //Déplacement vers la gauche
|
||||||
}
|
}
|
||||||
else if(action == 5)
|
else if(action == 5)
|
||||||
{
|
{
|
||||||
@ -74,16 +106,50 @@ int PlayerInterface(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Partie ajoutée
|
||||||
|
// On place le joueur à la bonne position
|
||||||
|
position.x = player1->PositionX * BLOC_SIZE;
|
||||||
|
position.y = player1->PositionY * BLOC_SIZE;
|
||||||
|
//SDL_BlitSurface(actualPlayer, NULL, SDL_GetWindowSurface(pWindow), &position);
|
||||||
|
|
||||||
|
// Effacement de l'écran
|
||||||
|
//SDL_FillRect(SDL_GetWindowSurface(pWindow), NULL, SDL_MapRGB(SDL_GetWindowSurface(pWindow)->format, 255, 255, 255));
|
||||||
|
|
||||||
|
SDL_BlitSurface(Sprites[FIRSTPLAYER], NULL, SDL_GetWindowSurface(pWindow), &position);
|
||||||
|
SDL_BlitSurface(Sprites[GRASS], NULL, SDL_GetWindowSurface(pWindow), &oldposition);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Tour de l'IA
|
//Tour de l'IA
|
||||||
IAEngine(player1,player2);
|
IAEngine(arena,player1,player2);
|
||||||
|
|
||||||
|
IAposition.x = player2->PositionX * BLOC_SIZE;
|
||||||
|
IAposition.y = player2->PositionY * BLOC_SIZE;
|
||||||
|
|
||||||
|
SDL_BlitSurface(Sprites[IA1], NULL, SDL_GetWindowSurface(pWindow), &IAposition);
|
||||||
|
SDL_BlitSurface(Sprites[GRASS], NULL, SDL_GetWindowSurface(pWindow), &oldIAposition);
|
||||||
|
|
||||||
|
SDL_UpdateWindowSurface(pWindow);
|
||||||
|
|
||||||
|
action=0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while(action != -1);
|
while((player1->HealthPoints >0) && (NumberPlayerAlive(List) > 1));
|
||||||
|
|
||||||
|
printf("La partie est terminée\n");
|
||||||
|
|
||||||
|
if(player1->HealthPoints > 0)
|
||||||
|
{
|
||||||
|
printf("Vous avez gagné\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("Vous avez perdu\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
//Si une des IA meurt, voir comment on le gère
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
//return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -97,63 +163,36 @@ int getEvent()
|
|||||||
{
|
{
|
||||||
/* Si c'est un événement de type "Quitter" */
|
/* Si c'est un événement de type "Quitter" */
|
||||||
case SDL_QUIT : printf("QUITTER\n");
|
case SDL_QUIT : printf("QUITTER\n");
|
||||||
action = -1;
|
//action = -1;
|
||||||
break;
|
//break;
|
||||||
|
return -1;
|
||||||
case SDL_KEYUP:
|
case SDL_KEYUP:
|
||||||
switch(event.key.keysym.sym) //La valeur de touche
|
switch(event.key.keysym.sym) //La valeur de touche
|
||||||
{
|
{
|
||||||
case SDLK_UP: printf("FLECHE DU HAUT\n");
|
case SDLK_UP: printf("FLECHE DU HAUT\n");
|
||||||
action = 1;
|
return 1;
|
||||||
break;
|
|
||||||
case SDLK_DOWN: printf("FLECHE DU BAS\n");
|
case SDLK_DOWN: printf("FLECHE DU BAS\n");
|
||||||
action = 3;
|
return 3;
|
||||||
break;
|
|
||||||
case SDLK_RIGHT: printf("FLECHE DE DROITE\n");
|
case SDLK_RIGHT:printf("FLECHE DE DROITE\n");
|
||||||
action = 2;
|
return 2;
|
||||||
break;
|
|
||||||
case SDLK_LEFT: printf("FLECHE DE GAUCHE\n");
|
case SDLK_LEFT: printf("FLECHE DE GAUCHE\n");
|
||||||
action = 4;
|
return 4;
|
||||||
break;
|
|
||||||
case SDLK_SPACE:printf("BARRE D'ESPACE\n");
|
case SDLK_SPACE:printf("BARRE D'ESPACE\n");
|
||||||
action = 5;
|
return 5;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return action;
|
|
||||||
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
|
|
||||||
ActionPlayer(player2,1); //Déplacement vers le haut
|
|
||||||
ActionPlayer(player2,2); //Déplacement vers la droite
|
|
||||||
ActionPlayer(player2,3); //Déplacement vers le bas
|
|
||||||
ActionPlayer(player2,4); //Déplacement vers la gauche
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
//freeElement(List, 2); // Fonctionne
|
|
||||||
//freeList(List); // Fonctionne
|
|
||||||
|
|
||||||
//displayList(List);
|
|
||||||
|
|
||||||
/** Pour la simulation d'un combat, on rentre la lettre A au clavier
|
|
||||||
* Le joueur 1 va attaqué le joueur 2 et inversement
|
|
||||||
* On affiche le score des joueurs
|
|
||||||
*
|
|
||||||
* */
|
|
||||||
//List = AttackPlayer(List, 1, 2);
|
|
||||||
|
|
||||||
// SDL_Quit();
|
|
||||||
|
|
||||||
|
|
||||||
/**Fonction qui crée un joueur
|
/**Fonction qui crée un joueur
|
||||||
*
|
*
|
||||||
* */
|
* */
|
||||||
@ -162,6 +201,7 @@ PLAYER* createPlayer(int Id)
|
|||||||
PLAYER* player=NULL;
|
PLAYER* player=NULL;
|
||||||
//Utilisé la fonction de récupération de la taille de l'arène
|
//Utilisé la fonction de récupération de la taille de l'arène
|
||||||
|
|
||||||
|
int race;
|
||||||
player=(PLAYER*)malloc(sizeof(PLAYER));
|
player=(PLAYER*)malloc(sizeof(PLAYER));
|
||||||
if(player==NULL)
|
if(player==NULL)
|
||||||
{
|
{
|
||||||
@ -170,10 +210,36 @@ PLAYER* createPlayer(int Id)
|
|||||||
|
|
||||||
printf("Entrer le nom du joueur\n");
|
printf("Entrer le nom du joueur\n");
|
||||||
scanf("%s",player->Name);
|
scanf("%s",player->Name);
|
||||||
printf("Nb PV?\n");
|
|
||||||
scanf("%d",&player->HealthPoints);
|
do
|
||||||
|
{
|
||||||
|
printf("Race? 1:Orc 2: Elf 3:Humain \n");
|
||||||
|
scanf("%d",&race);
|
||||||
|
}
|
||||||
|
while((race < 1) || (race > 3));
|
||||||
|
|
||||||
|
player->Race = race;
|
||||||
|
|
||||||
|
switch(race)
|
||||||
|
{
|
||||||
|
//Race ORC
|
||||||
|
case 1: player->HealthPoints = 100;
|
||||||
|
player->AttacksPoints = 10;
|
||||||
|
break;
|
||||||
|
|
||||||
|
//Race Elfe
|
||||||
|
case 2: player->HealthPoints = 80;
|
||||||
|
player->AttacksPoints = 9;
|
||||||
|
break;
|
||||||
|
|
||||||
|
//Race Humaine
|
||||||
|
case 3: player->HealthPoints = 90;
|
||||||
|
player->AttacksPoints = 9;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
player->Id = Id;
|
player->Id = Id;
|
||||||
player->AttacksPoints = 10;
|
//player->AttacksPoints = 10;
|
||||||
|
|
||||||
if(Id == 1)
|
if(Id == 1)
|
||||||
{
|
{
|
||||||
@ -182,18 +248,19 @@ PLAYER* createPlayer(int Id)
|
|||||||
}
|
}
|
||||||
else if(Id ==2)
|
else if(Id ==2)
|
||||||
{
|
{
|
||||||
player->PositionX=ArenaMAX;
|
player->PositionX=ARENAMAX - 1;
|
||||||
|
//player->PositionX=5;
|
||||||
player->PositionY=0;
|
player->PositionY=0;
|
||||||
}
|
}
|
||||||
else if(Id ==3)
|
else if(Id ==3)
|
||||||
{
|
{
|
||||||
player->PositionX=0;
|
player->PositionX=0;
|
||||||
player->PositionY=ArenaMAX;
|
player->PositionY=ARENAMAX - 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
player->PositionX=ArenaMAX;
|
player->PositionX=ARENAMAX - 1;
|
||||||
player->PositionY=ArenaMAX;
|
player->PositionY=ARENAMAX - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
player->suiv=NULL;
|
player->suiv=NULL;
|
||||||
@ -333,7 +400,6 @@ PLAYER * SearchPlayer(PLAYER *Head, int idPlayer)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AttackPlayer( PLAYER *player1, PLAYER *player2)
|
void AttackPlayer( PLAYER *player1, PLAYER *player2)
|
||||||
{
|
{
|
||||||
printf("Fonction Attaque\n");
|
printf("Fonction Attaque\n");
|
||||||
@ -342,8 +408,9 @@ void AttackPlayer( PLAYER *player1, PLAYER *player2)
|
|||||||
if((player1 != NULL) && (player2 != NULL))
|
if((player1 != NULL) && (player2 != NULL))
|
||||||
{
|
{
|
||||||
|
|
||||||
while((player1->HealthPoints > 0) && (player2->HealthPoints > 0))
|
if((player1->HealthPoints > 0) && (player2->HealthPoints > 0))
|
||||||
{
|
{
|
||||||
|
|
||||||
printf("\n\n** Tour **\n");
|
printf("\n\n** Tour **\n");
|
||||||
|
|
||||||
printf("Attaque Joueur %d sur joueur %d \n",player1->Id,player2->Id);
|
printf("Attaque Joueur %d sur joueur %d \n",player1->Id,player2->Id);
|
||||||
@ -353,33 +420,21 @@ void AttackPlayer( PLAYER *player1, PLAYER *player2)
|
|||||||
printf("Joueur %d : %s PV = %d\n ",player1->Id,player1->Name,player1->HealthPoints);
|
printf("Joueur %d : %s PV = %d\n ",player1->Id,player1->Name,player1->HealthPoints);
|
||||||
printf("Joueur %d : %s PV = %d\n ",player2->Id,player2->Name,player2->HealthPoints);
|
printf("Joueur %d : %s PV = %d\n ",player2->Id,player2->Name,player2->HealthPoints);
|
||||||
|
|
||||||
if((player1->HealthPoints > 0) && (player2->HealthPoints > 0))
|
/*if((player1->HealthPoints > 0) && (player2->HealthPoints > 0))
|
||||||
{
|
{
|
||||||
printf("\nAttaque Joueur %d sur joueur %d\n ",player2->Id,player1->Id);
|
printf("\nAttaque Joueur %d sur joueur %d\n ",player2->Id,player1->Id);
|
||||||
player1->HealthPoints = player1->HealthPoints - player2->AttacksPoints;
|
player1->HealthPoints = player1->HealthPoints - player2->AttacksPoints;
|
||||||
|
|
||||||
printf("Joueur %d : %s PV = %d\n ",player1->Id,player1->Name,player1->HealthPoints);
|
printf("Joueur %d : %s PV = %d\n ",player1->Id,player1->Name,player1->HealthPoints);
|
||||||
printf("Joueur %d : %s PV = %d \n",player2->Id,player2->Name,player2->HealthPoints);
|
printf("Joueur %d : %s PV = %d \n",player2->Id,player2->Name,player2->HealthPoints);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
if(player1->HealthPoints > player2->HealthPoints)
|
|
||||||
{
|
|
||||||
printf("Combat finie \n Le joueur 1 a gagné le combat\n");
|
|
||||||
}
|
|
||||||
else if(player1->HealthPoints < player2->HealthPoints)
|
|
||||||
{
|
|
||||||
printf("Combat finie \n Le joueur 2 a gagné le combat\n");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("Combat finie \n Les 2 joueurs sont morts");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ActionPlayer(PLAYER * player, int action)
|
void ActionPlayer(ARENA_H_TILE* arena,PLAYER * player, int action)
|
||||||
{
|
{
|
||||||
/* action = 1 --> Déplacement d'1 carreau vers le haut
|
/* action = 1 --> Déplacement d'1 carreau vers le haut
|
||||||
* action = 2 --> Déplacement d'1 carreau vers la droite
|
* action = 2 --> Déplacement d'1 carreau vers la droite
|
||||||
@ -387,6 +442,8 @@ void ActionPlayer(PLAYER * player, int action)
|
|||||||
* action = 4 --> Déplacement d'1 carreau vers la gauche
|
* action = 4 --> Déplacement d'1 carreau vers la gauche
|
||||||
*
|
*
|
||||||
* */
|
* */
|
||||||
|
int ID;
|
||||||
|
|
||||||
|
|
||||||
if(player != NULL)
|
if(player != NULL)
|
||||||
{
|
{
|
||||||
@ -396,7 +453,116 @@ void ActionPlayer(PLAYER * player, int action)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
printf("\n**** Player %s ****",player->Name);
|
printf("\n**** Player %s ****\n",player->Name);
|
||||||
|
|
||||||
|
if(action == 1)
|
||||||
|
{
|
||||||
|
printf("On veut aller vers le haut\n");
|
||||||
|
ID = getTileTypeID(arena, positionX, positionY -1);
|
||||||
|
printf("ID case[%i][%i] : %i \n",positionX,positionY-1,ID);
|
||||||
|
|
||||||
|
if((positionY-1 >= 0) && (ID == 0))
|
||||||
|
{
|
||||||
|
player->PositionY = positionY-1;
|
||||||
|
printf("Déplacement de 1 vers le haut\n La nouvelle position est de X: %i et Y: %i \n",player->PositionX,player->PositionY);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("Impossible d'aller vers le haut\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(action == 2)
|
||||||
|
{
|
||||||
|
printf("On veut aller vers la droite\n");
|
||||||
|
ID = getTileTypeID(arena, positionX + 1, positionY);
|
||||||
|
printf("ID case[%i][%i] : %i \n",positionX+1,positionY,ID);
|
||||||
|
|
||||||
|
if((positionX + 1 < ARENAMAX) && (ID == 0))
|
||||||
|
{
|
||||||
|
player->PositionX = positionX + 1;
|
||||||
|
printf("Déplacement de 1 vers la droite\n La nouvelle position est de X: %i et Y: %i \n",player->PositionX,player->PositionY);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("Impossible d'aller vers la droite\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(action == 3)
|
||||||
|
{
|
||||||
|
printf("On veut aller vers le bas\n");
|
||||||
|
ID = getTileTypeID(arena, positionX, positionY + 1);
|
||||||
|
printf("ID case[%i][%i] : %i \n",positionX,positionY+1,ID);
|
||||||
|
|
||||||
|
if((positionY + 1 < ARENAMAX) && (ID == 0))
|
||||||
|
{
|
||||||
|
player->PositionY = positionY + 1;
|
||||||
|
printf("Déplacement de 1 vers le bas\n La nouvelle position est de X: %i et Y: %i \n",player->PositionX,player->PositionY);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("Impossible d'aller vers le bas\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(action == 4)
|
||||||
|
{
|
||||||
|
printf("On veut aller vers la gauche\n");
|
||||||
|
ID = getTileTypeID(arena, positionX - 1, positionY);
|
||||||
|
printf("ID case[%i][%i] : %i \n",positionX-1,positionY,ID);
|
||||||
|
|
||||||
|
if((positionX - 1 >= 0) && (ID == 0))
|
||||||
|
{
|
||||||
|
player->PositionX = positionX - 1;
|
||||||
|
printf("Déplacement de 1 vers la gauche\n La nouvelle position est de X: %i et Y: %i \n",player->PositionX,player->PositionY);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("Impossible d'aller vers la gauche\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("Autre action\n");
|
||||||
|
ID = getTileTypeID(arena, positionX, positionY -1);
|
||||||
|
printf("ID case[%i][%i] : %i \n",positionX,positionY-1,ID);
|
||||||
|
|
||||||
|
ID = getTileTypeID(arena, positionX + 1, positionY);
|
||||||
|
printf("ID case[%i][%i] : %i \n",positionX+1,positionY,ID);
|
||||||
|
|
||||||
|
ID = getTileTypeID(arena, positionX, positionY + 1);
|
||||||
|
printf("ID case[%i][%i] : %i \n",positionX+1,positionY,ID);
|
||||||
|
|
||||||
|
ID = getTileTypeID(arena, positionX - 1, positionY);
|
||||||
|
printf("ID case[%i][%i] : %i \n",positionX-1,positionY,ID);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("Echec, le joueur est NULL\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
void ActionPlayer(PLAYER * player, int action)
|
||||||
|
{
|
||||||
|
/* action = 1 --> Déplacement d'1 carreau vers le haut
|
||||||
|
* action = 2 --> Déplacement d'1 carreau vers la droite
|
||||||
|
* action = 3 --> Déplacement d'1 carreau vers le bas
|
||||||
|
* action = 4 --> Déplacement d'1 carreau vers la gauche
|
||||||
|
*
|
||||||
|
*
|
||||||
|
|
||||||
|
if(player != NULL)
|
||||||
|
{
|
||||||
|
// récupère la position du personnage. La position de l'instance sur l'arène est récupérer par une fonction
|
||||||
|
int positionX = player->PositionX;
|
||||||
|
int positionY = player->PositionY;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
printf("\n**** Player %s ****\n",player->Name);
|
||||||
|
|
||||||
if(action == 1)
|
if(action == 1)
|
||||||
{
|
{
|
||||||
@ -416,7 +582,7 @@ void ActionPlayer(PLAYER * player, int action)
|
|||||||
{
|
{
|
||||||
printf("On veut aller vers la droite\n");
|
printf("On veut aller vers la droite\n");
|
||||||
|
|
||||||
if(positionX + 1 <= ArenaMAX)
|
if(positionX + 1 < ARENAMAX)
|
||||||
{
|
{
|
||||||
player->PositionX = positionX + 1;
|
player->PositionX = positionX + 1;
|
||||||
printf("Déplacement de 1 vers la droite\n La nouvelle position est de X: %i et Y: %i \n",player->PositionX,player->PositionY);
|
printf("Déplacement de 1 vers la droite\n La nouvelle position est de X: %i et Y: %i \n",player->PositionX,player->PositionY);
|
||||||
@ -430,7 +596,7 @@ void ActionPlayer(PLAYER * player, int action)
|
|||||||
{
|
{
|
||||||
printf("On veut aller vers le bas\n");
|
printf("On veut aller vers le bas\n");
|
||||||
|
|
||||||
if(positionY + 1 <= ArenaMAX)
|
if(positionY + 1 < ARENAMAX)
|
||||||
{
|
{
|
||||||
player->PositionY = positionY + 1;
|
player->PositionY = positionY + 1;
|
||||||
printf("Déplacement de 1 vers le bas\n La nouvelle position est de X: %i et Y: %i \n",player->PositionX,player->PositionY);
|
printf("Déplacement de 1 vers le bas\n La nouvelle position est de X: %i et Y: %i \n",player->PositionX,player->PositionY);
|
||||||
@ -447,7 +613,7 @@ void ActionPlayer(PLAYER * player, int action)
|
|||||||
if(positionX - 1 >= 0)
|
if(positionX - 1 >= 0)
|
||||||
{
|
{
|
||||||
player->PositionX = positionX - 1;
|
player->PositionX = positionX - 1;
|
||||||
printf("Déplacement de 1 vers le bas\n La nouvelle position est de X: %i et Y: %i \n",player->PositionX,player->PositionY);
|
printf("Déplacement de 1 vers la gauche\n La nouvelle position est de X: %i et Y: %i \n",player->PositionX,player->PositionY);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -463,6 +629,5 @@ void ActionPlayer(PLAYER * player, int action)
|
|||||||
{
|
{
|
||||||
printf("Echec, le joueur est NULL\n");
|
printf("Echec, le joueur est NULL\n");
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
* Created on: 17 juin 2018
|
* Created on: 17 juin 2018
|
||||||
* Author: isen
|
* Author: isen
|
||||||
*/
|
*/
|
||||||
|
#include "arenaEngine.h"
|
||||||
|
|
||||||
#ifndef PLAYERINTERFACE_H_
|
#ifndef PLAYERINTERFACE_H_
|
||||||
#define PLAYERINTERFACE_H_
|
#define PLAYERINTERFACE_H_
|
||||||
@ -15,7 +16,8 @@ typedef struct Player
|
|||||||
{
|
{
|
||||||
int Id;
|
int Id;
|
||||||
char Name[35];
|
char Name[35];
|
||||||
char Race[20];
|
//char Race[20];
|
||||||
|
int Race;
|
||||||
|
|
||||||
int HealthPoints;
|
int HealthPoints;
|
||||||
int AttacksPoints;
|
int AttacksPoints;
|
||||||
@ -23,6 +25,7 @@ typedef struct Player
|
|||||||
|
|
||||||
int PositionX;
|
int PositionX;
|
||||||
int PositionY;
|
int PositionY;
|
||||||
|
|
||||||
//char Weapons[Max_Weapons];
|
//char Weapons[Max_Weapons];
|
||||||
|
|
||||||
//int Coins;
|
//int Coins;
|
||||||
@ -41,9 +44,14 @@ PLAYER * freeList(PLAYER *Head);
|
|||||||
|
|
||||||
PLAYER * SearchPlayer(PLAYER *Head, int idPlayer);
|
PLAYER * SearchPlayer(PLAYER *Head, int idPlayer);
|
||||||
void AttackPlayer( PLAYER *player1, PLAYER *player2);
|
void AttackPlayer( PLAYER *player1, PLAYER *player2);
|
||||||
void ActionPlayer(PLAYER * player, int action);
|
//void ActionPlayer(PLAYER * player, int action);
|
||||||
|
void ActionPlayer(ARENA_H_TILE* arena,PLAYER * player, int action);
|
||||||
|
|
||||||
int NumberPlayerAlive(PLAYER *Head);
|
int NumberPlayerAlive(PLAYER *Head);
|
||||||
int getEvent(void);
|
int getEvent(void);
|
||||||
|
|
||||||
|
#define ARENAMAX 20
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* PLAYERINTERFACE_H_ */
|
#endif /* PLAYERINTERFACE_H_ */
|
||||||
|
BIN
stone_resize.png
Executable file
BIN
stone_resize.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
BIN
tree_resize.png
Executable file
BIN
tree_resize.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
BIN
zombie_resize.png
Executable file
BIN
zombie_resize.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
Loading…
x
Reference in New Issue
Block a user