Ajout menu fonctionnel + réglage beug score
This commit is contained in:
parent
6b14cf17e8
commit
d0285048f5
@ -1,10 +1,8 @@
|
|||||||
#ifndef MENU_H
|
#ifndef MENU_H
|
||||||
#define MENU_H
|
#define MENU_H
|
||||||
|
|
||||||
typedef struct {
|
void Menu_debut(void);
|
||||||
int x, y, L, H;
|
int Menu(void);
|
||||||
} zone;
|
int Menu_fin(void);
|
||||||
int check_zone(zone z, int x, int y);
|
void bordure(int segment);
|
||||||
void afficher_menu(zone jouer, zone quitter, int *jeu);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
Binary file not shown.
Before Width: | Height: | Size: 997 KiB |
BIN
SAE_semestre1/img/image.jpg
Normal file
BIN
SAE_semestre1/img/image.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 331 KiB |
Binary file not shown.
Before Width: | Height: | Size: 4.0 KiB |
Binary file not shown.
Before Width: | Height: | Size: 4.0 KiB |
Binary file not shown.
Before Width: | Height: | Size: 4.0 KiB |
Binary file not shown.
Before Width: | Height: | Size: 4.0 KiB |
@ -1,6 +1,7 @@
|
|||||||
#include <graph.h>
|
#include <graph.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "../fichier.h/Oeuf.h"
|
#include "../fichier.h/Oeuf.h"
|
||||||
|
#include "../fichier.h/time.h"
|
||||||
|
|
||||||
void InitialiserOeufs(int oeufx[], int oeufy[], int segment) {
|
void InitialiserOeufs(int oeufx[], int oeufy[], int segment) {
|
||||||
int p;
|
int p;
|
||||||
@ -22,6 +23,8 @@ void Oeuf(int pos_x[], int pos_y[], int oeufx[], int oeufy[], int *segment){
|
|||||||
(*segment) +=2;
|
(*segment) +=2;
|
||||||
oeufx[p] = ((rand() % (55)+1)*20);
|
oeufx[p] = ((rand() % (55)+1)*20);
|
||||||
oeufy[p] = ((rand() % (35)+1)*20);
|
oeufy[p] = ((rand() % (35)+1)*20);
|
||||||
|
Score(*segment);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -10,9 +10,9 @@
|
|||||||
#define CYCLE 100000L
|
#define CYCLE 100000L
|
||||||
|
|
||||||
int lancer_jeu(){
|
int lancer_jeu(){
|
||||||
|
int go_on=1;
|
||||||
int pause = 1;
|
int pause = 1;
|
||||||
int segment = 10;
|
int segment = 10;
|
||||||
int go_on = 1;
|
|
||||||
int direction = 4;
|
int direction = 4;
|
||||||
int minute = 0;
|
int minute = 0;
|
||||||
int seconde = 0;
|
int seconde = 0;
|
||||||
@ -29,7 +29,6 @@ int lancer_jeu(){
|
|||||||
int mury[30];
|
int mury[30];
|
||||||
char timer[6];
|
char timer[6];
|
||||||
int *pointeur_segment = &segment;
|
int *pointeur_segment = &segment;
|
||||||
int *pointeur_go_on = &go_on;
|
|
||||||
int *pointeur_direction = &direction;
|
int *pointeur_direction = &direction;
|
||||||
int *pointeur_minute = &minute;
|
int *pointeur_minute = &minute;
|
||||||
int *pointeur_seconde = &seconde;
|
int *pointeur_seconde = &seconde;
|
||||||
@ -41,14 +40,14 @@ int lancer_jeu(){
|
|||||||
old_seconde=(suivant/1000000)%10;
|
old_seconde=(suivant/1000000)%10;
|
||||||
DessinerScene(murx, mury, minute, seconde ,timer);
|
DessinerScene(murx, mury, minute, seconde ,timer);
|
||||||
InitialiserOeufs(oeufx, oeufy, segment);
|
InitialiserOeufs(oeufx, oeufy, segment);
|
||||||
Serpent(pos_x, pos_y, old_x, old_y, pointeur_segment, murx, mury, pointeur_go_on, pointeur_direction);
|
Serpent(pos_x, pos_y, old_x, old_y, pointeur_segment, murx, mury, &go_on, pointeur_direction);
|
||||||
while(go_on){
|
bordure(segment);
|
||||||
Controle(pointeur_direction, 0, pointeur_go_on, pointeur_pause);
|
while(go_on==1){
|
||||||
|
Controle(pointeur_direction, 0, &go_on, pointeur_pause);
|
||||||
if(pause == 1){
|
if(pause == 1){
|
||||||
Timer( pointeur_minute, pointeur_seconde, pointeur_suivant, pointeur_seconde_actuel, pointeur_old_seconde, timer);
|
Timer( pointeur_minute, pointeur_seconde, pointeur_suivant, pointeur_seconde_actuel, pointeur_old_seconde, timer);
|
||||||
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);
|
||||||
Collision_Serpent(pos_x, pos_y, segment, murx, mury, pointeur_go_on);
|
Collision_Serpent(pos_x, pos_y, segment, murx, mury, &go_on);
|
||||||
Score(segment);
|
|
||||||
usleep(100000);
|
usleep(100000);
|
||||||
Oeuf(pos_x, pos_y, oeufx, oeufy, pointeur_segment);
|
Oeuf(pos_x, pos_y, oeufx, oeufy, pointeur_segment);
|
||||||
}
|
}
|
||||||
@ -56,12 +55,12 @@ int lancer_jeu(){
|
|||||||
}
|
}
|
||||||
int main(void){
|
int main(void){
|
||||||
int choix = 0;
|
int choix = 0;
|
||||||
|
int go_on = 1;
|
||||||
InitialiserGraphique();
|
InitialiserGraphique();
|
||||||
CreerFenetre(350,100,1200,900);
|
CreerFenetre(350,100,1200,900);
|
||||||
EffacerEcran(CouleurParComposante(0,0,0));
|
EffacerEcran(CouleurParComposante(0,0,0));
|
||||||
afficher_menu(&choix);
|
Menu();
|
||||||
|
if(Menu() == 1){
|
||||||
while( choix == 1){
|
|
||||||
lancer_jeu();
|
lancer_jeu();
|
||||||
}
|
}
|
||||||
FermerGraphique();
|
FermerGraphique();
|
||||||
|
@ -1,24 +1,46 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
|
||||||
#include <graph.h>
|
#include <graph.h>
|
||||||
#include "../fichier.h/menu.h"
|
#include <stdio.h>
|
||||||
|
#include "../fichier.h/main.h"
|
||||||
int check_zone(zone z, int x, int y) {
|
#include "../fichier.h/time.h"
|
||||||
return x >= z.x && x <= z.x + z.L && y >= z.y && y <= z.y + z.H;
|
void Menu_debut(void) {
|
||||||
|
int af = ChargerSprite("../img/image.jpg");
|
||||||
|
AfficherSprite(af, 0, 0);
|
||||||
}
|
}
|
||||||
|
int Menu(void) {
|
||||||
|
int choix = 1;
|
||||||
|
InitialiserGraphique();
|
||||||
|
Menu_debut();
|
||||||
|
|
||||||
void afficher_menu(zone jouer, zone quitter, int *choix) {
|
while (1) {
|
||||||
ChargerImageFond("../img/Menu.png");
|
if (ToucheEnAttente()) {
|
||||||
while(1){
|
int touche = Touche();
|
||||||
SourisPosition();
|
switch (touche) {
|
||||||
|
case XK_e:
|
||||||
if(SourisCliquee()){
|
choix = 1;
|
||||||
int x = _X;
|
return choix;
|
||||||
int y = _Y;
|
/* Code pour traiter la touche "e" (fermer le jeu, par exemple)*/
|
||||||
if (check_zone(jouer, _X, _Y)){
|
case XK_a: /* Changement de XK_q à XK_a*/
|
||||||
*choix = 1;
|
/*Code pour traiter la touche "a" (fermer le jeu, par exemple)*/
|
||||||
|
FermerGraphique();
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
return;
|
return;
|
||||||
|
/* Ajoutez d'autres cas pour d'autres touches si nécessaire*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
int Menu_fin(void){
|
||||||
|
int fin = ChargerSprite("../img/Menu_Fin.png");
|
||||||
|
AfficherSprite(fin, 0,0);
|
||||||
|
Menu();
|
||||||
|
}
|
||||||
|
|
||||||
|
void bordure(int segment){
|
||||||
|
ChoisirCouleurDessin(CouleurParComposante(0,0,0));
|
||||||
|
RemplirRectangle(20,720,1180,200);
|
||||||
|
RemplirRectangle(0,0,20,900);
|
||||||
|
RemplirRectangle(0,0,1200,20);
|
||||||
|
RemplirRectangle(1180,0,1200,900);
|
||||||
|
Score(segment);
|
||||||
|
}
|
@ -36,11 +36,11 @@ void Update_Serpent(int pos_x[], int pos_y[], int segment, int old_x[], int old_
|
|||||||
void Collision_Serpent(int pos_x[], int pos_y[], int segment, int murx[], int mury[], int *go_on){
|
void Collision_Serpent(int pos_x[], int pos_y[], int segment, int murx[], int mury[], int *go_on){
|
||||||
int i;
|
int i;
|
||||||
/*Serpent contre coté*/
|
/*Serpent contre coté*/
|
||||||
if (pos_x[0] >1160 || pos_x[0]<=0){
|
if (pos_x[0] >1180 || pos_x[0]<=0){
|
||||||
*go_on=0;
|
*go_on=0;
|
||||||
}
|
}
|
||||||
/*Serpent contre coté*/
|
/*Serpent contre coté*/
|
||||||
if (pos_y[0]<20 || pos_y[0] >=700){
|
if (pos_y[0]<20 || pos_y[0] >=720){
|
||||||
*go_on=0;
|
*go_on=0;
|
||||||
}
|
}
|
||||||
/*Serpent contre Serpent*/
|
/*Serpent contre Serpent*/
|
||||||
|
@ -11,8 +11,8 @@ void Score(int segment){
|
|||||||
char score[4];
|
char score[4];
|
||||||
nombre= (segment-10)*25;
|
nombre= (segment-10)*25;
|
||||||
snprintf(score,4,"%04d0", nombre);
|
snprintf(score,4,"%04d0", nombre);
|
||||||
ChoisirCouleurDessin(CouleurParNom("black"));
|
ChoisirCouleurDessin(CouleurParComposante(0,0,0));
|
||||||
RemplirRectangle(1100,700,1200,800);
|
RemplirRectangle(950,725,1300,800);
|
||||||
ChoisirCouleurDessin(CouleurParNom("white"));
|
ChoisirCouleurDessin(CouleurParNom("white"));
|
||||||
EcrireTexte(1000,760,"Score: ",2);
|
EcrireTexte(1000,760,"Score: ",2);
|
||||||
EcrireTexte(1100,760,score,2);
|
EcrireTexte(1100,760,score,2);
|
||||||
@ -20,7 +20,7 @@ void Score(int segment){
|
|||||||
void Update_Timer(int minute, int seconde, char timer[]){
|
void Update_Timer(int minute, int seconde, char timer[]){
|
||||||
snprintf(timer,6,"%02d:%02d", minute, seconde);
|
snprintf(timer,6,"%02d:%02d", minute, seconde);
|
||||||
ChoisirCouleurDessin(CouleurParComposante(0,0,0));
|
ChoisirCouleurDessin(CouleurParComposante(0,0,0));
|
||||||
RemplirRectangle(10,700,12000,800);
|
RemplirRectangle(20,735,200,75);
|
||||||
ChoisirCouleurDessin(CouleurParComposante(255,255,255));
|
ChoisirCouleurDessin(CouleurParComposante(255,255,255));
|
||||||
EcrireTexte(50,760,"time: ",2);
|
EcrireTexte(50,760,"time: ",2);
|
||||||
EcrireTexte(120,760,timer,2);
|
EcrireTexte(120,760,timer,2);
|
||||||
|
Loading…
Reference in New Issue
Block a user