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