ajout menu mais non fonctionnel
This commit is contained in:
@@ -5,10 +5,12 @@
|
||||
#include "../fichier.h/Oeuf.h"
|
||||
#include "../fichier.h/time.h"
|
||||
#include "../fichier.h/main.h"
|
||||
#include "../fichier.h/menu.h"
|
||||
|
||||
#define CYCLE 10000L
|
||||
#define CYCLE 100000L
|
||||
|
||||
int main(void){
|
||||
int lancer_jeu(){
|
||||
int pause = 1;
|
||||
int segment = 10;
|
||||
int go_on = 1;
|
||||
int direction = 4;
|
||||
@@ -34,23 +36,35 @@ int main(void){
|
||||
unsigned long int *pointeur_suivant = &suivant;
|
||||
int *pointeur_seconde_actuel = &seconde_actuel;
|
||||
int *pointeur_old_seconde = &old_seconde;
|
||||
InitialiserGraphique();
|
||||
CreerFenetre(350,100,1200,900);
|
||||
EffacerEcran(CouleurParComposante(0,0,0));
|
||||
int *pointeur_pause = &pause;
|
||||
suivant = Microsecondes()+CYCLE;
|
||||
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);
|
||||
if(pause == 1){
|
||||
Timer( pointeur_minute, pointeur_seconde, pointeur_suivant, pointeur_seconde_actuel, pointeur_old_seconde, timer);
|
||||
Score(segment);
|
||||
Controle(pointeur_direction, 0, pointeur_go_on);
|
||||
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);
|
||||
usleep(100000);
|
||||
Oeuf(pos_x, pos_y, oeufx, oeufy, pointeur_segment);
|
||||
}
|
||||
}
|
||||
}
|
||||
int main(void){
|
||||
int choix = 0;
|
||||
InitialiserGraphique();
|
||||
CreerFenetre(350,100,1200,900);
|
||||
EffacerEcran(CouleurParComposante(0,0,0));
|
||||
afficher_menu(&choix);
|
||||
|
||||
while( choix == 1){
|
||||
lancer_jeu();
|
||||
}
|
||||
FermerGraphique();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,25 +1,24 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <graph.h>
|
||||
#include "../fichier.h/menu.h"
|
||||
|
||||
|
||||
int MenuDebut(){
|
||||
InitialiserGraphique();
|
||||
EcrireTexte(1000,760,"Score", 2);
|
||||
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;
|
||||
}
|
||||
int menu(){
|
||||
while(menu){
|
||||
while(ToucheEnAttente()){
|
||||
t = Touche();
|
||||
switch(t3){
|
||||
case XK_q :
|
||||
FermerGraphique();
|
||||
return EXIT_SUCCESS;
|
||||
return;
|
||||
case XK_Right :
|
||||
menu = 0;
|
||||
return
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ 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) {
|
||||
void Controle(int *direction, int last_direction, int *go_on, int *pause) {
|
||||
int t;
|
||||
while(ToucheEnAttente()) {
|
||||
t = Touche();
|
||||
@@ -86,8 +86,13 @@ void Controle(int *direction, int last_direction, int *go_on) {
|
||||
*direction = 0;
|
||||
*go_on = 0;
|
||||
return;
|
||||
case XK_p:
|
||||
*direction = 0;
|
||||
case XK_space:
|
||||
if (*pause == 0 ){
|
||||
*pause == 1;
|
||||
}else{
|
||||
*pause = 0;
|
||||
ChargerImage("../img/PAUSE.png", 400,200,0,0,350,300);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "../fichier.h/time.h"
|
||||
#include "../fichier.h/main.h"
|
||||
#include "../fichier.h/serpent.h"
|
||||
#define CYCLE 10000L
|
||||
#define CYCLE 100000L
|
||||
|
||||
void Score(int segment){
|
||||
int nombre;
|
||||
|
||||
Reference in New Issue
Block a user