modification du nom des fichiers
This commit is contained in:
62
prog/plateauinit.c
Normal file
62
prog/plateauinit.c
Normal file
@@ -0,0 +1,62 @@
|
||||
/* Création du plateau de jeu avec les pastilles et le serpent
|
||||
|
||||
written by Yann KERAUDREN and Titouan LERICHE*/
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#define LIGNES 40
|
||||
#define COLONNES 60
|
||||
#define NBR_POMME 5
|
||||
#define TAILLE_SERPENT 10
|
||||
|
||||
int* plateauinit(void) {
|
||||
|
||||
int tableau[LIGNES][COLONNES] = {0}, ligne_pomme, colonne_pomme, i, i2, compteur = 0 ;
|
||||
|
||||
srand(time(NULL));
|
||||
|
||||
|
||||
|
||||
|
||||
/* positionnement du serpent */
|
||||
|
||||
for (i = 0; i < TAILLE_SERPENT; i++) {
|
||||
|
||||
tableau[((LIGNES/2)-5)+i][COLONNES/2] = 1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* positionnement alétoire des pommes */
|
||||
|
||||
for ( i = 0; i < NBR_POMME; i++) {
|
||||
|
||||
|
||||
ligne_pomme = rand() % 40;
|
||||
colonne_pomme = rand() % 60;
|
||||
|
||||
|
||||
/* teste pour faire apparaitre exactement 5 pommes */
|
||||
|
||||
while (tableau[ligne_pomme][colonne_pomme] == 2) {
|
||||
|
||||
ligne_pomme = rand() % 40;
|
||||
colonne_pomme = rand() % 60;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* le chiffre definit une pomme */
|
||||
|
||||
tableau[ligne_pomme][colonne_pomme] = 2;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return tableau;
|
||||
}
|
Reference in New Issue
Block a user