This commit is contained in:
Thomas ROGNANT 2023-12-14 12:21:34 +01:00
parent 6895ca77f7
commit 1a083ffb39
2 changed files with 22 additions and 5 deletions

14
#Makefile# Normal file
View File

@ -0,0 +1,14 @@
CC = gcc
CFLAGS = -Wall -Wextra -I.
LIBS = -lgraph
all: serpent
serpent: main.o serpent.o
$() $() $^ -o $@ $()
%.o: %.c
$() $() -c $< -o $@
clean:
rm -f *.o serpent

View File

@ -68,8 +68,6 @@ void InitialiserJeu(Serpent* serpent, Pommes* pommes, Obstacles* obstacles) {
obstacles->positions[i].y = rand() % HAUTEUR; obstacles->positions[i].y = rand() % HAUTEUR;
} }
} }
void Graphique() { void Graphique() {
InitialiserGraphique(); InitialiserGraphique();
CreerFenetre(1, 1, 1240, 940); CreerFenetre(1, 1, 1240, 940);
@ -106,6 +104,13 @@ void AfficheTemps(int minute, int seconde) {
ChoisirCouleurDessin(CouleurParComposante(255, 255, 255)); ChoisirCouleurDessin(CouleurParComposante(255, 255, 255));
EcrireTexte(20, 900, temps, 2); EcrireTexte(20, 900, temps, 2);
} }
void AfficherEcranFin(int score) {
EffacerEcran(CouleurParComposante(0, 0, 0));
EcrireTexte(500, 300, "Game Over!", 2);
char scoreText[20];
snprintf(scoreText, 20, "Score: %d", score);
EcrireTexte(500, 400, scoreText, 2);
}
int PauseJeu() { int PauseJeu() {
while (1) { while (1) {
if (ToucheEnAttente()) { if (ToucheEnAttente()) {
@ -311,9 +316,7 @@ int GestionCollision(Serpent* serpent, Pommes* pommes, Obstacles* obstacles, int
loose = 1; loose = 1;
} }
if (CollisionAvecObstacle(serpent, obstacles) || CollisionAvecSerpent(serpent) || CollisionAvecBordures(serpent)) { if (CollisionAvecObstacle(serpent, obstacles) || CollisionAvecSerpent(serpent) || CollisionAvecBordures(serpent)) {
EffacerEcran(CouleurParComposante(0, 0, 0)); AfficherEcranFin(*score);
EcrireTexte(500, 400, "Game Over!", 2);
Attendre(1000); Attendre(1000);
loose = -1; loose = -1;
} }