modification jeu.c + ajout jeu.h
This commit is contained in:
parent
dfb98b4b2f
commit
9da1d232b2
6
include/jeu.h
Normal file
6
include/jeu.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef JEU_H
|
||||
#define JEU_H
|
||||
|
||||
void lancer_jeu1(void);
|
||||
|
||||
#endif /*JEU_H*/
|
43
src/jeu.c
43
src/jeu.c
@ -1,8 +1,45 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <graph.h>
|
||||
#include <unistd.h>
|
||||
#include "../include/grille.h"
|
||||
#include "../include/serpent.h"
|
||||
#include "../include/pomme.h"
|
||||
#include "../include/jeu.h"
|
||||
|
||||
void lancerJeu() {
|
||||
|
||||
}
|
||||
void lancer_jeu1(void) {
|
||||
Segment serpent[100];
|
||||
int longueur = 5;
|
||||
int direction_x = 1;
|
||||
int direction_y = 0;
|
||||
int i;
|
||||
InitialiserGraphique();
|
||||
CreerFenetre(0, 0, 1200, 1000);
|
||||
|
||||
|
||||
initialiserSerpent(serpent, &longueur);
|
||||
dessinerGrille(); /*Dessiner la grille*/
|
||||
|
||||
Pomme pomme = creerPomme();
|
||||
dessinerPomme(pomme);
|
||||
|
||||
while (1) {
|
||||
gestionDeplacements(serpent, &direction_x, &direction_y);
|
||||
mettreAJourSerpent(serpent, &longueur, &direction_x, &direction_y);
|
||||
|
||||
if (serpent[0].x == pomme.x && serpent[0].y == pomme.y) {
|
||||
longueur++;
|
||||
pomme = creerPomme(); /*Générer une pomme*/
|
||||
dessinerPomme(pomme);
|
||||
}
|
||||
|
||||
if (tuerSerpent(serpent) || seMangerQueue(serpent, longueur)) {
|
||||
/*Si le serpent est mort, gestion du game over*
|
||||
/*Ajoutez ici menu game over*/
|
||||
/*ChargerImageFond("../img/game_over.png");*/
|
||||
}
|
||||
|
||||
dessinerSerpent(serpent, &longueur);
|
||||
usleep(100000);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user