ajout mur

This commit is contained in:
Jude Christ AISSI 2023-12-11 16:21:27 +01:00
parent 41e8d812da
commit 182af0f304

View File

@ -2,7 +2,6 @@
#include <stdio.h> #include <stdio.h>
#include <graph.h> #include <graph.h>
#include <time.h> #include <time.h>
#include <unistd.h>
#define CYCLE 10000L #define CYCLE 10000L
@ -40,6 +39,10 @@ int fond;
int nombre; int nombre;
char score[4]; char score[4];
int murx[50];
int mury[50];
int mur;
void DessinerScene(){ void DessinerScene(){
snprintf(timer,6,"%02d:%02d", minute ,seconde); snprintf(timer,6,"%02d:%02d", minute ,seconde);
ChoisirCouleurDessin(CouleurParComposante(91,222,122)); ChoisirCouleurDessin(CouleurParComposante(91,222,122));
@ -48,6 +51,7 @@ void DessinerScene(){
EcrireTexte(10,760,timer,2); EcrireTexte(10,760,timer,2);
serpent=ChargerSprite("../img/serpent.png"); serpent=ChargerSprite("../img/serpent.png");
fond = ChargerSprite("../img/fond.png"); fond = ChargerSprite("../img/fond.png");
mur = ChargerSprite("../img/mur.png");
for (i = 0; i < segment; i++){ for (i = 0; i < segment; i++){
AfficherSprite(serpent, x-(i*20), y); AfficherSprite(serpent, x-(i*20), y);
@ -63,15 +67,28 @@ void DessinerScene(){
pommey[p] = ((rand() % (35)+1)*20); pommey[p] = ((rand() % (35)+1)*20);
AfficherSprite(pomme, pommex[p],pommey[p]); AfficherSprite(pomme, pommex[p],pommey[p]);
} }
for(i=0; i<20; i++){
murx[i] = ((rand() % (55)+1)*20);
mury[i] = ((rand() % (35)+1)*20);
AfficherSprite(mur, murx[i], mury[i]);
}
}
void Score(){
nombre= (segment-10)*10;
snprintf(score,4,"%04d0", nombre);
ChoisirCouleurDessin(CouleurParNom("black"));
RemplirRectangle(1100,700,1200,800);
ChoisirCouleurDessin(CouleurParNom("white"));
EcrireTexte(1000,760,"Score: ",2);
EcrireTexte(1100,760,score,2);
} }
void Update_Timer(){ void Update_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,1200,800); RemplirRectangle(10,700,1160,800);
ChoisirCouleurDessin(CouleurParComposante(255,255,255)); ChoisirCouleurDessin(CouleurParComposante(255,255,255));
EcrireTexte(50,760,timer,2); EcrireTexte(50,760,"time: ",2);
EcrireTexte(120,760,timer,2);
} }
void Update_Serpent(){ void Update_Serpent(){
@ -194,19 +211,22 @@ void Pomme(){
AfficherSprite(pomme, pommex[pp], pommey[pp]); AfficherSprite(pomme, pommex[pp], pommey[pp]);
} }
} }
void Score(){ void Mur(){
nombre= (segment-2)*10; for(i=0; i<20;i++){
snprintf(score,4,"%04d0", nombre); if(pos_x[0] == murx[i] && pos_y[0] == mury[i]){
ChoisirCouleurDessin(CouleurParNom("black")); ChoisirCouleurDessin(CouleurParNom("red"));
RemplirRectangle(1100,730,1200,800); RemplirRectangle(murx[i],mury[i], 20,20);
ChoisirCouleurDessin(CouleurParNom("white")); go_on=0;
EcrireTexte(1100,780,score,2); sleep(1);
}
}
} }
int main(){ int main(){
InitialiserGraphique(); InitialiserGraphique();
CreerFenetre(350,100,1200,800); CreerFenetre(350,100,1200,900);
EffacerEcran(CouleurParComposante(0,0,0)); EffacerEcran(CouleurParComposante(0,0,0));
suivant = Microsecondes()+CYCLE; suivant = Microsecondes()+CYCLE;
old_seconde=(suivant/1000000)%10; old_seconde=(suivant/1000000)%10;
@ -218,6 +238,7 @@ int main(){
Controle(); Controle();
Serpent(); Serpent();
Pomme(); Pomme();
Mur();
} }
FermerGraphique(); FermerGraphique();
return EXIT_SUCCESS; return EXIT_SUCCESS;