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