ajout commentaire + organisation du code + réglage menu pause

This commit is contained in:
Jude Christ AISSI 2023-12-24 18:42:04 +01:00
parent b9e58985ea
commit 95411d5a1f
7 changed files with 39 additions and 44 deletions

Binary file not shown.

View File

@ -8,7 +8,7 @@
void InitialiserOeufs(int oeufx[], int oeufy[], int segment) { void InitialiserOeufs(int oeufx[], int oeufy[], int segment) {
int p; int p;
int oeuf; int oeuf;
/*Boucles qui initialse 5 pommes aléatoirement*/ /*Boucles qui initialse 5 oeufs aléatoirement*/
for (p = 0; p < 5; p++) { for (p = 0; p < 5; p++) {
oeufx[p] = ((rand() % (55) + 1) * 20); oeufx[p] = ((rand() % (55) + 1) * 20);
oeufy[p] = ((rand() % (35) + 1) * 20); oeufy[p] = ((rand() % (35) + 1) * 20);

View File

@ -59,6 +59,7 @@ int lancer_jeu(){
Serpent(pos_x, pos_y, old_x, old_y, pointeur_segment, murx, mury, &go_on, pointeur_direction); Serpent(pos_x, pos_y, old_x, old_y, pointeur_segment, murx, mury, &go_on, pointeur_direction);
bordure(segment); bordure(segment);
Update_Serpent(pos_x, pos_y, segment, old_x, old_y, pointeur_direction); Update_Serpent(pos_x, pos_y, segment, old_x, old_y, pointeur_direction);
/*Lancement du jeu*/
while(go_on==1){ while(go_on==1){
Controle(pointeur_direction, 0, &go_on, pointeur_pause); Controle(pointeur_direction, 0, &go_on, pointeur_pause);
if(pause == 1){ if(pause == 1){
@ -90,5 +91,4 @@ int main(void){
lancer_jeu(); lancer_jeu();
} }
FermerGraphique(); FermerGraphique();
return EXIT_SUCCESS;
} }

View File

@ -1,6 +1,5 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <graph.h> #include <graph.h>
#include "../fichier.h/main.h" #include "../fichier.h/main.h"
@ -19,7 +18,6 @@ int Menu(void) {
int choix = 1; int choix = 1;
InitialiserGraphique(); InitialiserGraphique();
Menu_debut(); Menu_debut();
while (1) { while (1) {
if (ToucheEnAttente()) { if (ToucheEnAttente()) {
int touche = Touche(); int touche = Touche();
@ -27,8 +25,7 @@ int Menu(void) {
case XK_e: case XK_e:
choix = 1; choix = 1;
return choix; return choix;
case XK_q: /* Changement de XK_q à XK_a*/ case XK_q:
/*Code pour traiter la touche "a" (fermer le jeu, par exemple)*/
FermerGraphique(); FermerGraphique();
return choix; return choix;
} }

View File

@ -79,7 +79,6 @@ void Collision_Serpent(int pos_x[], int pos_y[], int segment, int murx[], int mu
void Controle(int *direction, int last_direction, int *go_on, int *pause) { void Controle(int *direction, int last_direction, int *go_on, int *pause) {
int t; int t;
int Pause = ChargerSprite("img/PAUSE.png");
while(ToucheEnAttente()) { while(ToucheEnAttente()) {
t = Touche(); t = Touche();
switch(t) { switch(t) {
@ -109,7 +108,7 @@ void Controle(int *direction, int last_direction, int *go_on, int *pause) {
return; return;
case XK_space : case XK_space :
*pause = 1; *pause = 1;
AfficherSprite(Pause, 400, 720); ChargerImage("img/PAUSE.png", 400,720,0,0,400,150);
while(*pause){ while(*pause){
t = Touche(); t = Touche();
if (t == XK_space){ if (t == XK_space){

View File

@ -1,7 +1,5 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <graph.h>
#include <time.h> #include <time.h>
#include <graph.h> #include <graph.h>

View File

@ -1,12 +1,13 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h>
#include <graph.h> #include <graph.h>
#include "../fichier.h/time.h" #include "../fichier.h/time.h"
#include "../fichier.h/main.h" #include "../fichier.h/main.h"
#include "../fichier.h/serpent.h" #include "../fichier.h/serpent.h"
#define CYCLE 1000000L #define CYCLE 1000000L
/*Affichage du score*/
void Score(int segment){ void Score(int segment){
int nombre; int nombre;
char score[4]; char score[4];