ajout menu mais non fonctionnel
This commit is contained in:
parent
8f26f7027d
commit
6b14cf17e8
@ -1,6 +1,7 @@
|
|||||||
#ifndef MAIN_H
|
#ifndef MAIN_H
|
||||||
#define MAIN_H
|
#define MAIN_H
|
||||||
|
|
||||||
int main(void);
|
int jeu(void);
|
||||||
|
int main(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -1,6 +1,10 @@
|
|||||||
#ifndef MENU_H
|
#ifndef MENU_H
|
||||||
#define MENU_H
|
#define MENU_H
|
||||||
|
|
||||||
void menu(void);
|
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);
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -4,5 +4,5 @@
|
|||||||
void Serpent(int pos_x[], int pos_y[], int old_x[], int old_y[], int *segment, int murx[], int mury[], int *go_on, int *direction);
|
void Serpent(int pos_x[], int pos_y[], int old_x[], int old_y[], int *segment, int murx[], int mury[], int *go_on, int *direction);
|
||||||
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);
|
||||||
void Update_Serpent(int pos_x[], int pos_y[], int segment, int old_x[], int old_y[], int*);
|
void Update_Serpent(int pos_x[], int pos_y[], int segment, int old_x[], int old_y[], int*);
|
||||||
void Controle(int *direction, int last_direction, int *go_on);
|
void Controle(int *direction, int last_direction, int *go_on, int *pause);
|
||||||
#endif
|
#endif
|
||||||
|
BIN
SAE_semestre1/img/tete_down.png
Normal file
BIN
SAE_semestre1/img/tete_down.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.0 KiB |
BIN
SAE_semestre1/img/tete_left.png
Normal file
BIN
SAE_semestre1/img/tete_left.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.0 KiB |
BIN
SAE_semestre1/img/tete_right.png
Normal file
BIN
SAE_semestre1/img/tete_right.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.0 KiB |
BIN
SAE_semestre1/img/tete_up.png
Normal file
BIN
SAE_semestre1/img/tete_up.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.0 KiB |
@ -5,10 +5,12 @@
|
|||||||
#include "../fichier.h/Oeuf.h"
|
#include "../fichier.h/Oeuf.h"
|
||||||
#include "../fichier.h/time.h"
|
#include "../fichier.h/time.h"
|
||||||
#include "../fichier.h/main.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 segment = 10;
|
||||||
int go_on = 1;
|
int go_on = 1;
|
||||||
int direction = 4;
|
int direction = 4;
|
||||||
@ -34,23 +36,35 @@ int main(void){
|
|||||||
unsigned long int *pointeur_suivant = &suivant;
|
unsigned long int *pointeur_suivant = &suivant;
|
||||||
int *pointeur_seconde_actuel = &seconde_actuel;
|
int *pointeur_seconde_actuel = &seconde_actuel;
|
||||||
int *pointeur_old_seconde = &old_seconde;
|
int *pointeur_old_seconde = &old_seconde;
|
||||||
InitialiserGraphique();
|
int *pointeur_pause = &pause;
|
||||||
CreerFenetre(350,100,1200,900);
|
|
||||||
EffacerEcran(CouleurParComposante(0,0,0));
|
|
||||||
suivant = Microsecondes()+CYCLE;
|
suivant = Microsecondes()+CYCLE;
|
||||||
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, pointeur_go_on, pointeur_direction);
|
||||||
while(go_on){
|
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);
|
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);
|
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, pointeur_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);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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();
|
FermerGraphique();
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,24 +1,23 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <graph.h>
|
||||||
#include "../fichier.h/menu.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;
|
||||||
|
}
|
||||||
|
|
||||||
int MenuDebut(){
|
void afficher_menu(zone jouer, zone quitter, int *choix) {
|
||||||
InitialiserGraphique();
|
ChargerImageFond("../img/Menu.png");
|
||||||
EcrireTexte(1000,760,"Score", 2);
|
while(1){
|
||||||
}
|
SourisPosition();
|
||||||
int menu(){
|
|
||||||
while(menu){
|
if(SourisCliquee()){
|
||||||
while(ToucheEnAttente()){
|
int x = _X;
|
||||||
t = Touche();
|
int y = _Y;
|
||||||
switch(t3){
|
if (check_zone(jouer, _X, _Y)){
|
||||||
case XK_q :
|
*choix = 1;
|
||||||
FermerGraphique();
|
|
||||||
return EXIT_SUCCESS;
|
|
||||||
return;
|
return;
|
||||||
case XK_Right :
|
|
||||||
menu = 0;
|
|
||||||
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;
|
int t;
|
||||||
while(ToucheEnAttente()) {
|
while(ToucheEnAttente()) {
|
||||||
t = Touche();
|
t = Touche();
|
||||||
@ -86,8 +86,13 @@ void Controle(int *direction, int last_direction, int *go_on) {
|
|||||||
*direction = 0;
|
*direction = 0;
|
||||||
*go_on = 0;
|
*go_on = 0;
|
||||||
return;
|
return;
|
||||||
case XK_p:
|
case XK_space:
|
||||||
*direction = 0;
|
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/time.h"
|
||||||
#include "../fichier.h/main.h"
|
#include "../fichier.h/main.h"
|
||||||
#include "../fichier.h/serpent.h"
|
#include "../fichier.h/serpent.h"
|
||||||
#define CYCLE 10000L
|
#define CYCLE 100000L
|
||||||
|
|
||||||
void Score(int segment){
|
void Score(int segment){
|
||||||
int nombre;
|
int nombre;
|
||||||
|
Loading…
Reference in New Issue
Block a user