avancement sur les déplacement du serpent
This commit is contained in:
@@ -14,10 +14,12 @@ struct adresse* plateau_init(void) {
|
||||
|
||||
int ligne_pomme, colonne_pomme, i;
|
||||
|
||||
|
||||
unsigned char* tete = NULL;
|
||||
unsigned char* queue = NULL;
|
||||
unsigned int* indice_queue = NULL;
|
||||
unsigned int* taille_serpent = NULL;
|
||||
|
||||
unsigned int** corps_serpent = NULL;
|
||||
|
||||
int** plateau = NULL;
|
||||
|
||||
|
||||
@@ -27,19 +29,28 @@ struct adresse* plateau_init(void) {
|
||||
srand(time(NULL));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* allocation du pointeur */
|
||||
|
||||
pointeur = malloc(sizeof( struct adresse));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* allocation du tableau tete et queue */
|
||||
|
||||
tete = malloc(2*sizeof(unsigned char));
|
||||
|
||||
queue = malloc(2*sizeof(unsigned char));
|
||||
indice_queue = malloc(sizeof(unsigned int));
|
||||
|
||||
/* allocation du tableau dans le tas */
|
||||
|
||||
|
||||
|
||||
|
||||
/* allocation du plateau dans le tas */
|
||||
|
||||
plateau = calloc(LIGNES, sizeof(int*));
|
||||
|
||||
@@ -49,9 +60,26 @@ struct adresse* plateau_init(void) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* allocation du corps du serpent */
|
||||
|
||||
corps_serpent = malloc(TAILLE_SERPENT * sizeof(unsigned int*));
|
||||
|
||||
for ( i = 0; i < TAILLE_SERPENT; i++) {
|
||||
|
||||
corps_serpent[i] = malloc( 2 * sizeof(unsigned int));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* allocation de la taille du serpent */
|
||||
|
||||
taille_serpent = malloc(sizeof(unsigned int));
|
||||
|
||||
|
||||
/* positionnement du serpent et marquage de la tete et la queue */
|
||||
|
||||
tete[0] = ((LIGNES/2)+(TAILLE_SERPENT/2)-1);
|
||||
@@ -59,13 +87,14 @@ struct adresse* plateau_init(void) {
|
||||
|
||||
|
||||
|
||||
queue[0] = ((LIGNES/2)-(TAILLE_SERPENT/2));
|
||||
queue[1] = COLONNES/2;
|
||||
|
||||
for (i = 0; i < TAILLE_SERPENT ; i++) {
|
||||
|
||||
plateau[((LIGNES/2)-5)+i][COLONNES/2] = 1;
|
||||
|
||||
|
||||
corps_serpent[i][0] = ((LIGNES/2)-5) + i;
|
||||
corps_serpent[i][1] = COLONNES/2;
|
||||
|
||||
}
|
||||
|
||||
@@ -96,11 +125,15 @@ struct adresse* plateau_init(void) {
|
||||
}
|
||||
|
||||
|
||||
*taille_serpent = TAILLE_SERPENT;
|
||||
|
||||
*indice_queue = 0;
|
||||
|
||||
pointeur -> plateau = plateau;
|
||||
pointeur -> tete = tete;
|
||||
pointeur -> queue = queue;
|
||||
|
||||
pointeur -> indice_queue = indice_queue;
|
||||
pointeur -> corps_serpent = corps_serpent;
|
||||
pointeur -> taille_serpent = taille_serpent;
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user