snake fini
This commit is contained in:
parent
9717f400c8
commit
be4518b53d
@ -9,7 +9,7 @@
|
||||
#define H 42
|
||||
#define L 62
|
||||
#define DELTO 1000L
|
||||
#define DELTI 900000L
|
||||
#define DELTI 400000L
|
||||
|
||||
int Semage(int tab[H][L], int direction, int sxmax, int symax, int *pause, int *fin);
|
||||
unsigned long TempsArret(int *temoin);
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
#define DELTA 1000000L;
|
||||
#define DELTO 1000L
|
||||
#define DELTI 900000L
|
||||
#define DELTI 400000L
|
||||
|
||||
void LancerJeu(void)
|
||||
{
|
||||
|
17
Snake/Menu.c
17
Snake/Menu.c
@ -54,19 +54,15 @@ int MenuDebut(void){
|
||||
c=CouleurParNom("white");
|
||||
ChoisirCouleurDessin(c);
|
||||
EcrireTexte(250,500,"Regle n1-Mangez un maximum de pommes pour grandir",1);
|
||||
|
||||
c=CouleurParNom("white");
|
||||
ChoisirCouleurDessin(c);
|
||||
EcrireTexte(250,550,"Regle n2-Ne vous prennez pas de murs , ou vous perdrez !",1);
|
||||
|
||||
c=CouleurParNom("white");
|
||||
ChoisirCouleurDessin(c);
|
||||
EcrireTexte(250,600,"Regle n3-Malheur a vous si vous prennez une prune surprise .",1);
|
||||
|
||||
c=CouleurParNom("white");
|
||||
ChoisirCouleurDessin(c);
|
||||
EcrireTexte(250,650,"Regle n4-N'oubliez pas de vous amuser ;)",1);
|
||||
|
||||
EcrireTexte(200,750,"Les Controles :",1);
|
||||
EcrireTexte(250,800,"-Deplacez vous avec les fleches du clavier",1);
|
||||
EcrireTexte(250,850,"-Mettez pause a tout moments grace a la touche espace",1);
|
||||
EcrireTexte(250,900,"-Vous pouvez mettre fin a la partie avec la touche echap",1);
|
||||
|
||||
while(1){
|
||||
if(SourisCliquee()==1){
|
||||
if(_X>=1300&&_Y>=100&&_X<=1600&&_Y<=300){
|
||||
@ -82,6 +78,7 @@ int MenuDebut(void){
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*Initialisation de la page*/
|
||||
void InitEcran(void){
|
||||
InitialiserGraphique();
|
||||
@ -146,7 +143,7 @@ int MenuFinGagne(void){
|
||||
RemplirRectangle(1300,700,300,200);
|
||||
|
||||
c=CouleurParNom("white");
|
||||
ChoisirCouleurDessin(c);
|
||||
ChoisirCouleurDessin(c);
|
||||
EcrireTexte(1400,450,"Recommencer",1);
|
||||
EcrireTexte(1400,750,"Quitter",1);
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "Afficher.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <graph.h>
|
||||
#include "Afficher.h"
|
||||
|
||||
/*affichage du plateau de jeu en fonction du tableau*/
|
||||
void AfficheTab(int tab[H][L], int posx, int posy, int i, int j){
|
||||
|
@ -13,21 +13,29 @@ int CliqueTouche(int defaut,int* pause,int* fin){
|
||||
if(defaut!=0){
|
||||
defaut=2;
|
||||
return defaut;
|
||||
}else{
|
||||
return defaut;
|
||||
}
|
||||
case XK_Down:
|
||||
if(defaut!=2){
|
||||
defaut=0;
|
||||
return defaut;
|
||||
}else{
|
||||
return defaut;
|
||||
}
|
||||
case XK_Right:
|
||||
if(defaut!=1){
|
||||
defaut=3;
|
||||
return defaut;
|
||||
}else{
|
||||
return defaut;
|
||||
}
|
||||
case XK_Left:
|
||||
if(defaut!=3){
|
||||
defaut=1;
|
||||
return defaut;
|
||||
}else{
|
||||
return defaut;
|
||||
}
|
||||
case XK_space:
|
||||
if(*pause==1){
|
||||
@ -95,7 +103,6 @@ void DeplacementQueue(int tab[H][L],int* sxmin,int* symin,int* direc, int menu){
|
||||
|
||||
/*Deplacement de la tete du seroent en fonction de la direction*/
|
||||
void DeplacementTete(int tab[H][L],int* sxmax,int* symax,int direction,int* temoin,int* fin,int* point,int mode){
|
||||
if(mode==1){
|
||||
if(direction==2){
|
||||
if(VerifChemin(tab,*sxmax-1,*symax)==1){
|
||||
*sxmax=*sxmax-1;
|
||||
@ -110,7 +117,11 @@ void DeplacementTete(int tab[H][L],int* sxmax,int* symax,int direction,int* temo
|
||||
}else if(VerifChemin(tab,*sxmax-1,*symax)==2){
|
||||
*sxmax=*sxmax-1;
|
||||
tab[*sxmax][*symax]=1;
|
||||
Pastille(tab,5,3);
|
||||
if(mode==3){
|
||||
Pastille(tab,20,3);
|
||||
}else{
|
||||
Pastille(tab,5,3);
|
||||
}
|
||||
Pastille(tab,1,2);
|
||||
}else{
|
||||
*fin=1;
|
||||
@ -130,8 +141,12 @@ void DeplacementTete(int tab[H][L],int* sxmax,int* symax,int direction,int* temo
|
||||
*temoin=1;
|
||||
}else if(VerifChemin(tab,*sxmax,*symax+1)==2){
|
||||
*symax=*symax+1;
|
||||
tab[*sxmax][*symax]=1;;
|
||||
Pastille(tab,5,3);
|
||||
tab[*sxmax][*symax]=1;
|
||||
if(mode==3){
|
||||
Pastille(tab,20,3);
|
||||
}else{
|
||||
Pastille(tab,5,3);
|
||||
}
|
||||
Pastille(tab,1,2);
|
||||
}else{
|
||||
*fin=1;
|
||||
@ -152,8 +167,12 @@ void DeplacementTete(int tab[H][L],int* sxmax,int* symax,int direction,int* temo
|
||||
*temoin=1;
|
||||
}else if(VerifChemin(tab,*sxmax,*symax-1)==2){
|
||||
*symax=*symax-1;
|
||||
tab[*sxmax][*symax]=1;;
|
||||
Pastille(tab,5,3);
|
||||
tab[*sxmax][*symax]=1;
|
||||
if(mode==3){
|
||||
Pastille(tab,20,3);
|
||||
}else{
|
||||
Pastille(tab,5,3);
|
||||
}
|
||||
Pastille(tab,1,2);
|
||||
}else{
|
||||
*fin=1;
|
||||
@ -174,183 +193,16 @@ void DeplacementTete(int tab[H][L],int* sxmax,int* symax,int direction,int* temo
|
||||
*temoin=1;
|
||||
}else if(VerifChemin(tab,*sxmax+1,*symax)==2){
|
||||
*sxmax=*sxmax+1;
|
||||
tab[*sxmax][*symax]=1;
|
||||
Pastille(tab,5,3);
|
||||
Pastille(tab,1,2);
|
||||
}else{
|
||||
*fin=1;
|
||||
}
|
||||
}/*aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa*/
|
||||
}if(mode==2){
|
||||
if(direction==2){
|
||||
if(VerifChemin(tab,*sxmax-1,*symax)==1){
|
||||
*sxmax=*sxmax-1;
|
||||
tab[*sxmax][*symax]=1;
|
||||
}else if(VerifChemin(tab,*sxmax-1,*symax)==3){
|
||||
*sxmax=*sxmax-1;
|
||||
tab[*sxmax][*symax]=1;
|
||||
*point=*point+5;
|
||||
DessinerScore(*point);
|
||||
Pastille(tab,1,1);
|
||||
*temoin=1;
|
||||
}else if(VerifChemin(tab,*sxmax-1,*symax)==2){
|
||||
*sxmax=*sxmax-1;
|
||||
tab[*sxmax][*symax]=1;
|
||||
Pastille(tab,5,3);
|
||||
tab[*sxmax][*symax]=1;
|
||||
if(mode==3){
|
||||
Pastille(tab,20,3);
|
||||
}else{
|
||||
Pastille(tab,5,3);
|
||||
}
|
||||
Pastille(tab,1,2);
|
||||
}else{
|
||||
*fin=1;
|
||||
}
|
||||
}
|
||||
/*droite*/
|
||||
if(direction==3){
|
||||
if(VerifChemin(tab,*sxmax,*symax+1)==1){
|
||||
*symax=*symax+1;
|
||||
tab[*sxmax][*symax]=1;
|
||||
}else if(VerifChemin(tab,*sxmax,*symax+1)==3){
|
||||
*symax=*symax+1;
|
||||
tab[*sxmax][*symax]=1;
|
||||
*point=*point+5;
|
||||
DessinerScore(*point);
|
||||
Pastille(tab,1,1);
|
||||
*temoin=1;
|
||||
}else if(VerifChemin(tab,*sxmax,*symax+1)==2){
|
||||
*symax=*symax+1;
|
||||
tab[*sxmax][*symax]=1;;
|
||||
Pastille(tab,5,3);
|
||||
Pastille(tab,1,2);
|
||||
}else{
|
||||
*fin=1;
|
||||
}
|
||||
}
|
||||
/*gauche*/
|
||||
if(direction==1){
|
||||
if(VerifChemin(tab,*sxmax,*symax-1)==1){
|
||||
*symax=*symax-1;
|
||||
tab[*sxmax][*symax]=1;
|
||||
}
|
||||
else if(VerifChemin(tab,*sxmax,*symax-1)==3){
|
||||
*symax=*symax-1;
|
||||
tab[*sxmax][*symax]=1;
|
||||
*point=*point+5;
|
||||
DessinerScore(*point);
|
||||
Pastille(tab,1,1);
|
||||
*temoin=1;
|
||||
}else if(VerifChemin(tab,*sxmax,*symax-1)==2){
|
||||
*symax=*symax-1;
|
||||
tab[*sxmax][*symax]=1;;
|
||||
Pastille(tab,5,3);
|
||||
Pastille(tab,1,2);
|
||||
}else{
|
||||
*fin=1;
|
||||
}
|
||||
}
|
||||
/*bas*/
|
||||
if(direction==0){
|
||||
if(VerifChemin(tab,*sxmax+1,*symax)==1){
|
||||
*sxmax=*sxmax+1;
|
||||
tab[*sxmax][*symax]=1;
|
||||
}
|
||||
else if(VerifChemin(tab,*sxmax+1,*symax)==3){
|
||||
*sxmax=*sxmax+1;
|
||||
tab[*sxmax][*symax]=1;
|
||||
*point=*point+5;
|
||||
DessinerScore(*point);
|
||||
Pastille(tab,1,1);
|
||||
*temoin=1;
|
||||
}else if(VerifChemin(tab,*sxmax+1,*symax)==2){
|
||||
*sxmax=*sxmax+1;
|
||||
tab[*sxmax][*symax]=1;
|
||||
Pastille(tab,5,3);
|
||||
Pastille(tab,1,2);
|
||||
}else{
|
||||
*fin=1;
|
||||
}
|
||||
/*aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa*/
|
||||
}}if(mode==3){
|
||||
if(direction==2){
|
||||
if(VerifChemin(tab,*sxmax-1,*symax)==1){
|
||||
*sxmax=*sxmax-1;
|
||||
tab[*sxmax][*symax]=1;
|
||||
}else if(VerifChemin(tab,*sxmax-1,*symax)==3){
|
||||
*sxmax=*sxmax-1;
|
||||
tab[*sxmax][*symax]=1;
|
||||
*point=*point+5;
|
||||
DessinerScore(*point);
|
||||
Pastille(tab,1,1);
|
||||
*temoin=1;
|
||||
}else if(VerifChemin(tab,*sxmax-1,*symax)==2){
|
||||
*sxmax=*sxmax-1;
|
||||
tab[*sxmax][*symax]=1;
|
||||
Pastille(tab,20,3);
|
||||
Pastille(tab,1,2);
|
||||
}else{
|
||||
*fin=1;
|
||||
}
|
||||
}
|
||||
/*droite*/
|
||||
if(direction==3){
|
||||
if(VerifChemin(tab,*sxmax,*symax+1)==1){
|
||||
*symax=*symax+1;
|
||||
tab[*sxmax][*symax]=1;
|
||||
}else if(VerifChemin(tab,*sxmax,*symax+1)==3){
|
||||
*symax=*symax+1;
|
||||
tab[*sxmax][*symax]=1;
|
||||
*point=*point+5;
|
||||
DessinerScore(*point);
|
||||
Pastille(tab,1,1);
|
||||
*temoin=1;
|
||||
}else if(VerifChemin(tab,*sxmax,*symax+1)==2){
|
||||
*symax=*symax+1;
|
||||
tab[*sxmax][*symax]=1;;
|
||||
Pastille(tab,20,3);
|
||||
Pastille(tab,1,2);
|
||||
}else{
|
||||
*fin=1;
|
||||
}
|
||||
}
|
||||
/*gauche*/
|
||||
if(direction==1){
|
||||
if(VerifChemin(tab,*sxmax,*symax-1)==1){
|
||||
*symax=*symax-1;
|
||||
tab[*sxmax][*symax]=1;
|
||||
}
|
||||
else if(VerifChemin(tab,*sxmax,*symax-1)==3){
|
||||
*symax=*symax-1;
|
||||
tab[*sxmax][*symax]=1;
|
||||
*point=*point+5;
|
||||
DessinerScore(*point);
|
||||
Pastille(tab,1,1);
|
||||
*temoin=1;
|
||||
}else if(VerifChemin(tab,*sxmax,*symax-1)==2){
|
||||
*symax=*symax-1;
|
||||
tab[*sxmax][*symax]=1;;
|
||||
Pastille(tab,20,3);
|
||||
Pastille(tab,1,2);
|
||||
}else{
|
||||
*fin=1;
|
||||
}
|
||||
}
|
||||
/*bas*/
|
||||
if(direction==0){
|
||||
if(VerifChemin(tab,*sxmax+1,*symax)==1){
|
||||
*sxmax=*sxmax+1;
|
||||
tab[*sxmax][*symax]=1;
|
||||
}
|
||||
else if(VerifChemin(tab,*sxmax+1,*symax)==3){
|
||||
*sxmax=*sxmax+1;
|
||||
tab[*sxmax][*symax]=1;
|
||||
*point=*point+5;
|
||||
DessinerScore(*point);
|
||||
Pastille(tab,1,1);
|
||||
*temoin=1;
|
||||
}else if(VerifChemin(tab,*sxmax+1,*symax)==2){
|
||||
*sxmax=*sxmax+1;
|
||||
tab[*sxmax][*symax]=1;
|
||||
Pastille(tab,20,3);
|
||||
Pastille(tab,1,2);
|
||||
}else{
|
||||
*fin=1;
|
||||
}
|
||||
}}
|
||||
}
|
||||
|
||||
}
|
74
Snake_ancien/Jeu.c
Normal file
74
Snake_ancien/Jeu.c
Normal file
@ -0,0 +1,74 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <graph.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "Afficher.h"
|
||||
#include "ModifTab.h"
|
||||
#include "Deplacement.h"
|
||||
#include "Chemin.h"
|
||||
#include "Menu.h"
|
||||
#include "Jeu.h"
|
||||
|
||||
#define DELTA 1000000L;
|
||||
#define DELTO 1000L
|
||||
#define DELTI 900000L
|
||||
|
||||
void LancerJeu(void)
|
||||
{
|
||||
int tab[H][L], direction = 0, temoin = 0, direc = 0, pause = 1,mode=0;
|
||||
int sxmin = 17, symin = 30, sxmax = 27, symax = 30, fin = 0, point = 0, Compteur_Temps = 0;
|
||||
int *pointeur_pause = &pause;
|
||||
int *pointeur_sxmin = &sxmin;
|
||||
int *pointeur_symin = &symin;
|
||||
int *pointeur_direc = &direc;
|
||||
int *pointeur_temoin = &temoin;
|
||||
int *pointeur_sxmax = &sxmax;
|
||||
int *pointeur_symax = &symax;
|
||||
int *pointeur_fin = &fin;
|
||||
int *pointeur_point = &point;
|
||||
unsigned long suivant = Microsecondes() + DELTA;
|
||||
unsigned long suivant2 = Microsecondes() + DELTO;
|
||||
unsigned long suivant3 = Microsecondes() + DELTO;
|
||||
|
||||
InitEcran();
|
||||
mode=MenuDebut();
|
||||
init(tab,mode);
|
||||
|
||||
while (1)
|
||||
{
|
||||
if(fin!=1)
|
||||
{
|
||||
Affiche(tab);
|
||||
if (ToucheEnAttente() == 1)
|
||||
{
|
||||
direction = Semage(tab, direction, sxmax, symax, pointeur_pause, pointeur_fin);
|
||||
}
|
||||
if (pause == 1) {
|
||||
if (Microsecondes() > suivant) {
|
||||
Compteur_Temps++;
|
||||
DessinerTimer(Compteur_Temps);
|
||||
suivant = Microsecondes() + DELTA;
|
||||
}
|
||||
if (Microsecondes() > suivant3) {
|
||||
DeplacementQueue(tab, pointeur_sxmin, pointeur_symin, pointeur_direc,mode);
|
||||
suivant3 = TempsArret(pointeur_temoin);
|
||||
}
|
||||
if (Microsecondes() > suivant2) {
|
||||
DeplacementTete(tab, pointeur_sxmax, pointeur_symax, direction, pointeur_temoin, pointeur_fin, pointeur_point,mode);
|
||||
suivant2 = Microsecondes() + DELTO;
|
||||
}
|
||||
MenuPause(pause);
|
||||
}else{
|
||||
MenuPause(pause);
|
||||
}
|
||||
}
|
||||
else if (fin == 1) {
|
||||
if(Gagne(tab)==0){
|
||||
MenuFinGagne();
|
||||
}else{
|
||||
MenuFinPerdu();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Snake_ancien/Jeu.h
Normal file
11
Snake_ancien/Jeu.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef JEU_H
|
||||
#define JEU_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <graph.h>
|
||||
#include <time.h>
|
||||
|
||||
void LancerJeu(void);
|
||||
|
||||
#endif
|
@ -2,6 +2,7 @@
|
||||
#include<stdlib.h>
|
||||
#include<graph.h>
|
||||
#include "Menu.h"
|
||||
#include "Jeu.h"
|
||||
|
||||
int MenuDebut(void){
|
||||
couleur c=CouleurParNom("green");
|
||||
@ -80,6 +81,7 @@ int MenuDebut(void){
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*Initialisation de la page*/
|
||||
void InitEcran(void){
|
||||
InitialiserGraphique();
|
||||
@ -90,15 +92,79 @@ void InitEcran(void){
|
||||
RemplirRectangle(0,0,1700,1000);
|
||||
}
|
||||
|
||||
void MenuFinPerdu(void){
|
||||
couleur c=CouleurParNom("white");
|
||||
void MenuPause(int pause){
|
||||
couleur c;
|
||||
if(pause == 0){
|
||||
c=CouleurParNom("white");
|
||||
ChoisirCouleurDessin(c);
|
||||
EcrireTexte(1350,200,"Dommage !",2);
|
||||
EcrireTexte(1280,250,"Peut-etre une prochaine fois",2);
|
||||
EcrireTexte(1330,450,"Menu pause (appuyez sur espace)",1);
|
||||
}else{
|
||||
c=CouleurParNom("dark blue");
|
||||
ChoisirCouleurDessin(c);
|
||||
RemplirRectangle(1330,300,500,500);
|
||||
}
|
||||
}
|
||||
|
||||
void MenuFinGagne(void){
|
||||
couleur c=CouleurParNom("white");
|
||||
int MenuFinPerdu(void){
|
||||
couleur c=CouleurParNom("purple");
|
||||
ChoisirCouleurDessin(c);
|
||||
RemplirRectangle(1300,400,300,200);
|
||||
c=CouleurParNom("red");
|
||||
ChoisirCouleurDessin(c);
|
||||
RemplirRectangle(1300,700,300,200);
|
||||
|
||||
c=CouleurParNom("white");
|
||||
ChoisirCouleurDessin(c);
|
||||
EcrireTexte(1400,450,"Recommencer",1);
|
||||
EcrireTexte(1400,750,"Quitter",1);
|
||||
|
||||
EcrireTexte(1350,200,"Dommage !",2);
|
||||
EcrireTexte(1280,250,"Peut-etre une prochaine fois",2);
|
||||
|
||||
while(1){
|
||||
if(SourisCliquee()==1){
|
||||
if(_X>=1300&&_Y>=400&&_X<=1600&&_Y<=600)
|
||||
{
|
||||
FermerGraphique();
|
||||
LancerJeu();
|
||||
}
|
||||
if(_X>=1300&&_Y>=700&&_X<=1600&&_Y<=900)
|
||||
{
|
||||
FermerGraphique();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int MenuFinGagne(void){
|
||||
couleur c=CouleurParNom("purple");
|
||||
ChoisirCouleurDessin(c);
|
||||
RemplirRectangle(1300,400,300,200);
|
||||
c=CouleurParNom("red");
|
||||
ChoisirCouleurDessin(c);
|
||||
RemplirRectangle(1300,700,300,200);
|
||||
|
||||
c=CouleurParNom("white");
|
||||
ChoisirCouleurDessin(c);
|
||||
EcrireTexte(1400,450,"Recommencer",1);
|
||||
EcrireTexte(1400,750,"Quitter",1);
|
||||
|
||||
EcrireTexte(1350,200,"Felicitations !",2);
|
||||
EcrireTexte(1280,200,"Vous etes trop fort !!",2);
|
||||
|
||||
while(1){
|
||||
if(SourisCliquee()==1){
|
||||
if(_X>=1300&&_Y>=400&&_X<=1600&&_Y<=600)
|
||||
{
|
||||
FermerGraphique();
|
||||
LancerJeu();
|
||||
}
|
||||
if(_X>=1300&&_Y>=700&&_X<=1600&&_Y<=900)
|
||||
{
|
||||
FermerGraphique();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,8 +7,9 @@
|
||||
#include <time.h>
|
||||
|
||||
int MenuDebut(void);
|
||||
void MenuFinGagne(void);
|
||||
void MenuFinPerdu(void);
|
||||
void InitEcran(void);
|
||||
int MenuFinPerdu(void);
|
||||
int MenuFinGagne(void);
|
||||
void MenuPause(int pause);
|
||||
|
||||
#endif // MENU_H
|
||||
|
@ -1,65 +1,5 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <graph.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "Afficher.h"
|
||||
#include "ModifTab.h"
|
||||
#include "Deplacement.h"
|
||||
#include "Chemin.h"
|
||||
#include "Menu.h"
|
||||
|
||||
#define DELTA 1000000L;
|
||||
#define DELTO 1000L
|
||||
#define DELTI 900000L
|
||||
#include "Jeu.h"
|
||||
|
||||
int main(void) {
|
||||
int tab[H][L], direction = 0, temoin = 0, direc = 0, pause = 1,mode=0;
|
||||
int sxmin = 17, symin = 30, sxmax = 27, symax = 30, fin = 0, point = 0, Compteur_Temps = 0;
|
||||
int *pointeur_pause = &pause;
|
||||
int *pointeur_sxmin = &sxmin;
|
||||
int *pointeur_symin = &symin;
|
||||
int *pointeur_direc = &direc;
|
||||
int *pointeur_temoin = &temoin;
|
||||
int *pointeur_sxmax = &sxmax;
|
||||
int *pointeur_symax = &symax;
|
||||
int *pointeur_fin = &fin;
|
||||
int *pointeur_point = &point;
|
||||
unsigned long suivant = Microsecondes() + DELTA;
|
||||
unsigned long suivant2 = Microsecondes() + DELTO;
|
||||
unsigned long suivant3 = Microsecondes() + DELTO;
|
||||
InitEcran();
|
||||
mode=MenuDebut();
|
||||
init(tab,mode);
|
||||
|
||||
while (1) {
|
||||
if(fin!=1){
|
||||
Affiche(tab);
|
||||
if (ToucheEnAttente() == 1) {
|
||||
direction = Semage(tab, direction, sxmax, symax, pointeur_pause, pointeur_fin);
|
||||
}
|
||||
if (pause == 1) {
|
||||
if (Microsecondes() > suivant) {
|
||||
Compteur_Temps++;
|
||||
DessinerTimer(Compteur_Temps);
|
||||
suivant = Microsecondes() + DELTA;
|
||||
}
|
||||
if (Microsecondes() > suivant3) {
|
||||
DeplacementQueue(tab, pointeur_sxmin, pointeur_symin, pointeur_direc,mode);
|
||||
suivant3 = TempsArret(pointeur_temoin);
|
||||
}
|
||||
if (Microsecondes() > suivant2) {
|
||||
DeplacementTete(tab, pointeur_sxmax, pointeur_symax, direction, pointeur_temoin, pointeur_fin, pointeur_point,mode);
|
||||
suivant2 = Microsecondes() + DELTO;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (fin == 1) {
|
||||
if(Gagne(tab)==0){
|
||||
MenuFinGagne();
|
||||
}else{
|
||||
MenuFinPerdu();
|
||||
}
|
||||
}
|
||||
}
|
||||
LancerJeu();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
exec : Chemin.o Deplacement.o Afficher.o ModifTab.o main.o Menu.o
|
||||
gcc -ansi -o exec Chemin.o Deplacement.o Afficher.o ModifTab.o main.o Menu.o -lgraph
|
||||
exec : Chemin.o Deplacement.o Afficher.o ModifTab.o main.o Menu.o Jeu.o
|
||||
gcc -ansi -o exec Chemin.o Deplacement.o Afficher.o ModifTab.o main.o Menu.o Jeu.o -lgraph
|
||||
run : exec
|
||||
./exec
|
||||
Chemin.o : Chemin.c
|
||||
@ -14,6 +14,8 @@ main.o : main.c
|
||||
gcc -c main.c -lgraph
|
||||
Menu.o : Menu.c
|
||||
gcc -c Menu.c -lgraph
|
||||
Jeu.o : Jeu.c
|
||||
gcc -c Jeu.c -lgraph
|
||||
clean :
|
||||
rm -f *~
|
||||
rm -f *.o
|
||||
|
Loading…
Reference in New Issue
Block a user