ajout sprite de la tete
BIN
JEUX_SERPENT/IMG/queue_down.png
Normal file
After Width: | Height: | Size: 4.2 KiB |
BIN
JEUX_SERPENT/IMG/queue_left.png
Normal file
After Width: | Height: | Size: 4.2 KiB |
BIN
JEUX_SERPENT/IMG/queue_right.png
Normal file
After Width: | Height: | Size: 4.2 KiB |
BIN
JEUX_SERPENT/IMG/queue_up.png
Normal file
After Width: | Height: | Size: 4.2 KiB |
BIN
JEUX_SERPENT/IMG/tete_down.png
Normal file
After Width: | Height: | Size: 4.2 KiB |
BIN
JEUX_SERPENT/IMG/tete_left.png
Normal file
After Width: | Height: | Size: 4.2 KiB |
BIN
JEUX_SERPENT/IMG/tete_right.png
Normal file
After Width: | Height: | Size: 4.2 KiB |
BIN
JEUX_SERPENT/IMG/tete_up.png
Normal file
After Width: | Height: | Size: 4.2 KiB |
@ -11,7 +11,7 @@ extern int seconde, minute, seconde_actuel, old_seconde;
|
||||
extern char timer[6];
|
||||
extern unsigned long int suivant;
|
||||
|
||||
extern int serpent;
|
||||
extern int serpent, tete_up, tete_down, tete_right, tete_left, queue_up, queue_down, queue_left, queue_right;
|
||||
extern int x, y, direction, t, segment, i;
|
||||
extern int pos_x[2400], pos_y[2400], old_x[2400], old_y[2400];
|
||||
|
||||
|
@ -14,6 +14,7 @@ unsigned long int suivant;
|
||||
int serpent;
|
||||
int x=500, y=360, direction=4 /*1 : vers le haut, 2 : vers le bas, 3 vers la gauche, 4 vers la droite*/, t, segment=10, i=0;
|
||||
int pos_x[2400], pos_y[2400], old_x[2400], old_y[2400];
|
||||
int tete_up, tete_down, tete_right, tete_left, queue_up, queue_down, queue_left, queue_right;
|
||||
|
||||
int p=0, pp=0, pomme, pommex[5], pommey[5];
|
||||
int fond, Nbr;
|
||||
@ -74,11 +75,6 @@ int main(){
|
||||
case XK_q :
|
||||
go_menu=0;
|
||||
break;
|
||||
/*case XK_r :
|
||||
system("make run");
|
||||
sleep(1);
|
||||
FermerGraphique();
|
||||
return EXIT_SUCCESS; */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,15 @@ void DessinerScene(){
|
||||
EcrireTexte(10,760,timer,2);
|
||||
serpent=ChargerSprite("IMG/serpent.png");
|
||||
fond=ChargerSprite("IMG/fond.png");
|
||||
tete_up = ChargerSprite("IMG/tete_up.png");
|
||||
tete_down =ChargerSprite("IMG/tete_down.png");
|
||||
tete_left = ChargerSprite("IMG/tete_left.png");
|
||||
tete_right = ChargerSprite("IMG/tete_right.png");
|
||||
queue_up = ChargerSprite("IMG/queue_up.png");
|
||||
queue_down = ChargerSprite("IMG/queue_down.png");
|
||||
queue_left = ChargerSprite("IMG/queue_left.png");
|
||||
queue_right = ChargerSprite("IMG/queue_right.png");
|
||||
|
||||
|
||||
for (i = 0; i < segment; i++){
|
||||
AfficherSprite(serpent, x-(i*20), y);
|
||||
|
@ -64,15 +64,46 @@ void Serpent(){
|
||||
|
||||
/*fonction pour mettre à jour la position du serpent*/
|
||||
void Update_Serpent(){
|
||||
|
||||
AfficherSprite(fond, pos_x[segment-1], pos_y[segment-1]);
|
||||
AfficherSprite(serpent, pos_x[0], pos_y[0]);
|
||||
/*affichage de la tete en fonction de la direction du serpent*/
|
||||
if (direction==1){
|
||||
AfficherSprite(tete_up, pos_x[0], pos_y[0]);
|
||||
}
|
||||
if (direction==2){
|
||||
AfficherSprite(tete_down, pos_x[0], pos_y[0]);
|
||||
}
|
||||
if (direction==3){
|
||||
AfficherSprite(tete_left, pos_x[0], pos_y[0]);
|
||||
}
|
||||
if (direction==4){
|
||||
AfficherSprite(tete_right, pos_x[0], pos_y[0]);
|
||||
}
|
||||
|
||||
/*affichage du reste du corps*/
|
||||
for (i=1 ; i<segment ; i++){
|
||||
pos_x[i]=old_x[i-1];
|
||||
pos_y[i]=old_y[i-1];
|
||||
AfficherSprite(serpent, pos_x[i], pos_y[i]);
|
||||
}
|
||||
/*affichage de la queue*/
|
||||
/*if (direction==1){
|
||||
AfficherSprite(queue_up, pos_x[segment], pos_y[segment-1]);
|
||||
}
|
||||
if (direction==2){
|
||||
AfficherSprite(queue_down, pos_x[segment-1], pos_y[segment-1]);
|
||||
}
|
||||
if (direction==3){
|
||||
AfficherSprite(queue_left, pos_x[segment-1], pos_y[segment-1]);
|
||||
}
|
||||
if (direction==4){
|
||||
AfficherSprite(queue_right, pos_x[segment-1],pos_y[segment-1]);
|
||||
}*/
|
||||
|
||||
ChoisirCouleurDessin(CouleurParComposante(0,0,0));
|
||||
RemplirRectangle(0,0,20,20);
|
||||
|
||||
/*Décalage des positions du serpent*/
|
||||
old_x[0]=pos_x[0];
|
||||
old_y[0]=pos_y[0];
|
||||
for (i=1 ; i<segment ; i++){
|
||||
|