Correction bug
This commit is contained in:
parent
3b588c6e7c
commit
371da48697
@ -10,7 +10,6 @@ int gestionDeplacements(Segment serpent[], int *direction_x, int *direction_y);
|
||||
int tuerSerpent(Segment serpent[], int longueur);
|
||||
void mettreAJourSerpent(Segment serpent[], int *longueur, int *direction_x, int *direction_y);
|
||||
void dessinerSerpent(Segment serpent[], int *longueur);
|
||||
int seMangerQueue(Segment serpent[], int longueur);
|
||||
void attendreSerpent(unsigned long int microseconds);
|
||||
|
||||
#endif /*SERPENT_H*/
|
||||
|
23
src/pomme.c
23
src/pomme.c
@ -2,16 +2,23 @@
|
||||
#include <graph.h>
|
||||
#include "../include/grille.h"
|
||||
#include "../include/serpent.h"
|
||||
#include "../include/pomme.h"
|
||||
|
||||
typedef struct {
|
||||
int x;
|
||||
int y;
|
||||
} Pomme;
|
||||
|
||||
Pomme creerPomme() {
|
||||
Pomme creerPomme(Segment serpent[], int longueur) {
|
||||
Pomme pomme;
|
||||
pomme.x = rand() % 60;
|
||||
pomme.y = rand() % 40;
|
||||
int i;
|
||||
int serpentOccupation[LARGEUR_GRILLE][HAUTEUR_GRILLE] = {0}; /*Utiliser les constantes de grille.h*/
|
||||
|
||||
/*Marquer les cases occupées par le serpent*/
|
||||
for (i = 0; i < longueur; ++i) {
|
||||
serpentOccupation[serpent[i].x][serpent[i].y] = 1;
|
||||
}
|
||||
|
||||
do {
|
||||
pomme.x = rand() % LARGEUR_GRILLE;
|
||||
pomme.y = rand() % HAUTEUR_GRILLE;
|
||||
} while (serpentOccupation[pomme.x][pomme.y]);
|
||||
|
||||
return pomme;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user