35 lines
762 B
C
35 lines
762 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include "player.h"
|
|
#include "board.h"
|
|
|
|
typedef struct {
|
|
int x, y; /* Position du pion*/
|
|
} Joueur;
|
|
|
|
static Joueur joueur1, joueur2;
|
|
|
|
void initialiser_joueurs() {
|
|
/* Initialisation des joueurs*/
|
|
joueur1.x = 0;
|
|
joueur1.y = 0;
|
|
joueur2.x = 1;
|
|
joueur2.y = 1;
|
|
printf("Joueurs initialisés.\n");
|
|
}
|
|
|
|
void deplacer_joueur(Joueur *j, int nouvelle_x, int nouvelle_y) {
|
|
if (est_case_libre(nouvelle_x, nouvelle_y)) {
|
|
j->x = nouvelle_x;
|
|
j->y = nouvelle_y;
|
|
printf("Le joueur a été déplacé.\n");
|
|
} else {
|
|
printf("Case non libre, impossible de déplacer le joueur.\n");
|
|
}
|
|
}
|
|
|
|
Joueur* obtenir_joueur(int numero) {
|
|
return (numero == 1) ? &joueur1 : &joueur2;
|
|
}
|
|
|