ajou du sprite du serpent + avancement automatique 1
This commit is contained in:
parent
e7e8e55a6c
commit
4c862a769b
BIN
JEUX_SERPENT/.nfs0000000002e8d7940000001d
Executable file
BIN
JEUX_SERPENT/.nfs0000000002e8d7940000001d
Executable file
Binary file not shown.
@ -7,16 +7,24 @@
|
||||
int seconde=0;
|
||||
int minute=0;
|
||||
char timer[10];
|
||||
|
||||
int go_on=1;
|
||||
|
||||
int serpent;
|
||||
int x = 580;
|
||||
int y = 350;
|
||||
int direction = 4; /*1 : vers le haut , 2 : vers le bas; 3 : vers la gauche, 4 : vers la droite*/
|
||||
|
||||
/*Fonction pour pouvoir mettre à jour/actualisé la scène (timer, position du serpent)*/
|
||||
void DessinerScene(){
|
||||
snprintf(timer,10,"%02d:%02d", minute, seconde);
|
||||
EffacerEcran(CouleurParComposante(0,0,0));
|
||||
ChoisirCouleurDessin(CouleurParComposante(141,199,63));
|
||||
RemplirRectangle(10,10,1180,700);
|
||||
RemplirRectangle(20,20,1160,700);
|
||||
ChoisirCouleurDessin(CouleurParComposante(255,255,255));
|
||||
EcrireTexte(10,760,timer,2);
|
||||
serpent=ChargerSprite("serpent.png");
|
||||
AfficherSprite(serpent, x, y);
|
||||
}
|
||||
|
||||
/*Fonction pour connaitre et afficher le temps*/
|
||||
@ -30,6 +38,23 @@ void Timer(){
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
void Serpent(){
|
||||
|
||||
if (direction == 1){
|
||||
y=y+20;
|
||||
}
|
||||
if (direction == 2){
|
||||
y=y-20;
|
||||
}
|
||||
if (direction == 3){
|
||||
x=x-20;
|
||||
}
|
||||
if (direction == 4){
|
||||
x=x+20;
|
||||
}
|
||||
sleep(0.1);
|
||||
}
|
||||
|
||||
/*Fonction Principale*/
|
||||
int main(){
|
||||
|
||||
@ -41,11 +66,11 @@ int main(){
|
||||
/*Boucle Principale du Programme*/
|
||||
while(go_on){
|
||||
Timer();
|
||||
Serpent();
|
||||
DessinerScene();
|
||||
}
|
||||
|
||||
/* fermeture de la fenêtre */
|
||||
Touche();
|
||||
FermerGraphique();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 549 B |
Loading…
Reference in New Issue
Block a user