réglage beug serpent + décors

This commit is contained in:
Jude Christ AISSI 2023-12-20 13:20:49 +01:00
parent b749e57f28
commit a04dd8902b
3 changed files with 19 additions and 20 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 600 B

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

@ -3,14 +3,14 @@
#include <stdio.h> #include <stdio.h>
#include <graph.h> #include <graph.h>
#include <time.h> #include <time.h>
#define CYCLE 10000L #define CYCLE 100000L
void DessinerScene(int murx[], int mury[], int minute, int seconde, char timer []){ void DessinerScene(int murx[], int mury[], int minute, int seconde, char timer []){
int mur; int mur;
int i; int i;
int fond; int fond;
snprintf(timer,6,"%02d:%02d", minute ,seconde); snprintf(timer,6,"%02d:%02d", minute ,seconde);
ChoisirCouleurDessin(CouleurParComposante(91,222,122)); ChoisirCouleurDessin(CouleurParComposante(79,80,35));
RemplirRectangle(20,20,1160,700); RemplirRectangle(20,20,1160,700);
ChoisirCouleurDessin(CouleurParComposante(255,255,255)); ChoisirCouleurDessin(CouleurParComposante(255,255,255));
fond = ChargerSprite("../img/fond.png"); fond = ChargerSprite("../img/fond.png");
@ -43,7 +43,7 @@ void Update_Timer(int minute, int seconde, char timer[]){
} }
void Update_Serpent(int pos_x[], int pos_y[], int segment, int old_x[], int old_y[], int* direction){ void Update_Serpent(int pos_x[], int pos_y[], int segment, int old_x[], int old_y[], int* direction){
int i = 0; int i = 0;
int serpent=ChargerSprite("../img/serpent.png"); int serpent=ChargerSprite("../img/serpent2.png");
int fond = ChargerSprite("../img/fond.png"); int fond = ChargerSprite("../img/fond.png");
for (i=1 ; i<segment ; i++){ for (i=1 ; i<segment ; i++){
pos_x[i]=old_x[i-1]; pos_x[i]=old_x[i-1];
@ -62,18 +62,17 @@ void Update_Serpent(int pos_x[], int pos_y[], int segment, int old_x[], int old_
if (*direction == 4) { if (*direction == 4) {
pos_x[0]=old_x[0]+20; pos_x[0]=old_x[0]+20;
} }
for (i=0 ; i<segment ; i++){
printf("serpent : %d %d\n",pos_x[i],pos_y[i]);
RemplirRectangle(pos_x[i], pos_y[i], 20,20);
}
for (i=0 ; i<segment ; i++){ for (i=0 ; i<segment ; i++){
printf("fond : %d %d\n",old_x[i],old_y[i]); printf("fond : %d %d\n",old_x[i],old_y[i]);
AfficherSprite(fond, old_x[i], old_y[i]); ChoisirCouleurDessin(CouleurParComposante(79,80,35));
RemplirRectangle(old_x[i], old_y[i], 20,20);
old_x[i]=pos_x[i]; old_x[i]=pos_x[i];
old_y[i]=pos_y[i]; old_y[i]=pos_y[i];
} }
for (i=0 ; i<segment ; i++){
printf("serpent : %d %d\n",pos_x[i],pos_y[i]);
AfficherSprite(serpent, pos_x[i], pos_y[i]);
}
} }
void Collision_Serpent(int pos_x[], int pos_y[], int segment, int murx[], int mury[], int *go_on){ void Collision_Serpent(int pos_x[], int pos_y[], int segment, int murx[], int mury[], int *go_on){
@ -189,11 +188,11 @@ void Pomme(int pos_x[], int pos_y[], int pommex[], int pommey[], int *segment){
} }
} }
} }
void Menu_debut(){ /*void Menu_debut(){
affiche = ChargerSprite("Img/image.png") affiche = ChargerSprite("Img/image.png");
AddicherSprite(affiche,0,0) AfficherSprite(affiche,0,0);
} }
Menu_debut(); Menu_debut();*/
int main(void){ int main(void){
@ -205,10 +204,10 @@ int main(void){
int seconde_actuel = 0; int seconde_actuel = 0;
int old_seconde = 0; int old_seconde = 0;
unsigned long int suivant; unsigned long int suivant;
int pos_x[60]; int pos_x[2400];
int pos_y[60]; int pos_y[2400];
int old_x[60]; int old_x[2400];
int old_y[60]; int old_y[2400];
int pommex[5]; int pommex[5];
int pommey[5]; int pommey[5];
int murx[30]; int murx[30];
@ -236,7 +235,7 @@ int main(void){
Controle(pointeur_direction, 0, pointeur_go_on); Controle(pointeur_direction, 0, pointeur_go_on);
Update_Serpent(pos_x, pos_y, segment, old_x, old_y, pointeur_direction); Update_Serpent(pos_x, pos_y, segment, old_x, old_y, pointeur_direction);
Collision_Serpent(pos_x, pos_y, segment, murx, mury, pointeur_go_on); Collision_Serpent(pos_x, pos_y, segment, murx, mury, pointeur_go_on);
usleep(1000000); usleep(100000);
Pomme(pos_x, pos_y, pommex, pommey, pointeur_segment); Pomme(pos_x, pos_y, pommex, pommey, pointeur_segment);
} }
FermerGraphique(); FermerGraphique();