jeu 100% fonctionnel manque le make file

This commit is contained in:
Jude Christ AISSI 2023-12-20 14:27:23 +01:00
parent a04dd8902b
commit 71c6743a35
2 changed files with 14 additions and 20 deletions

BIN
SAE_semestre1/img/pomme.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -13,13 +13,11 @@ void DessinerScene(int murx[], int mury[], int minute, int seconde, char timer [
ChoisirCouleurDessin(CouleurParComposante(79,80,35)); 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");
mur = ChargerSprite("../img/mur.png");
srand(time(NULL)); srand(time(NULL));
for(i=0; i<30; i++){ for(i=0; i<30; i++){
murx[i] = ((rand() % (55)+1)*20); murx[i] = ((rand() % (55)+1)*20);
mury[i] = ((rand() % (35)+1)*20); mury[i] = ((rand() % (35)+1)*20);
AfficherSprite(mur, murx[i], mury[i]); ChargerImage("../img/mur.png", murx[i], mury[i],0,0, 20,20);
} }
} }
void Score(int segment){ void Score(int segment){
@ -43,8 +41,6 @@ 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/serpent2.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];
pos_y[i]=old_y[i-1]; pos_y[i]=old_y[i-1];
@ -64,27 +60,27 @@ void Update_Serpent(int pos_x[], int pos_y[], int segment, int old_x[], int old_
} }
for (i=0 ; i<segment ; i++){ for (i=0 ; i<segment ; i++){
printf("serpent : %d %d\n",pos_x[i],pos_y[i]); printf("serpent : %d %d\n",pos_x[i],pos_y[i]);
RemplirRectangle(pos_x[i], pos_y[i], 20,20); ChargerImage("../img/serpent2.png", pos_x[i], pos_y[i],0,0, 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]);
ChoisirCouleurDessin(CouleurParComposante(79,80,35)); ChoisirCouleurDessin(CouleurParComposante(79,80,35));
RemplirRectangle(old_x[i], old_y[i], 20,20); RemplirRectangle(pos_x[segment-1], pos_y[segment-1], 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];
} }
} }
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){
int mur;
int i; int i;
mur = ChargerSprite("../img/mur.png");
/*Serpent contre coté*/ /*Serpent contre coté*/
if (pos_x[0] >1160 || pos_x[0]<=20){ if (pos_x[0] >1160 || pos_x[0]<=0){
*go_on=0; *go_on=0;
} }
/*Serpent contre coté*/ /*Serpent contre coté*/
if (pos_y[0]<40 || pos_y[0] >=700){ if (pos_y[0]<20 || pos_y[0] >=700){
*go_on=0; *go_on=0;
} }
/*Serpent contre Serpent*/ /*Serpent contre Serpent*/
@ -153,9 +149,9 @@ void Controle(int *direction, int last_direction, int *go_on) {
} }
void Serpent(int pos_x[], int pos_y[], int old_x[], int old_y[], int *segment, int murx[], int mury[], int *go_on, int *direction) { void Serpent(int pos_x[], int pos_y[], int old_x[], int old_y[], int *segment, int murx[], int mury[], int *go_on, int *direction) {
int serpent; int serpent;
int i = 0;
pos_x[0] = 600; pos_x[0] = 600;
pos_y[0] = 400; pos_y[0] = 400;
int i = 0;
for (i = 0; i < *segment; i++){ for (i = 0; i < *segment; i++){
pos_x[i]= pos_x[0]; pos_x[i]= pos_x[0];
pos_y[i]= pos_y[0]; pos_y[i]= pos_y[0];
@ -166,24 +162,22 @@ void Serpent(int pos_x[], int pos_y[], int old_x[], int old_y[], int *segment, i
void InitialiserPommes(int pommex[], int pommey[], int segment) { void InitialiserPommes(int pommex[], int pommey[], int segment) {
int p; int p;
int pomme; int pomme;
pomme = ChargerSprite("../img/pomme.png");
for (p = 0; p < 5; p++) { for (p = 0; p < 5; p++) {
pommex[p] = ((rand() % (55) + 1) * 20); pommex[p] = ((rand() % (55) + 1) * 20);
pommey[p] = ((rand() % (35) + 1) * 20); pommey[p] = ((rand() % (35) + 1) * 20);
AfficherSprite(pomme, pommex[p], pommey[p]); ChargerImage("../img/pomme.png", pommex[p], pommey[p],0,0, 20,20);
} }
} }
void Pomme(int pos_x[], int pos_y[], int pommex[], int pommey[], int *segment){ void Pomme(int pos_x[], int pos_y[], int pommex[], int pommey[], int *segment){
int p; int p;
int pomme; int pomme;
pomme=ChargerSprite("../img/pomme.png");
for (p = 0; p < 5; p++) { for (p = 0; p < 5; p++) {
AfficherSprite(pomme, pommex[p],pommey[p]); ChargerImage("../img/pomme.png", pommex[p], pommey[p],0,0, 20,20);
} }
for(p=0; p<5; p++){ for(p=0; p<5; p++){
if(pommex[p]==pos_x[0] && pommey[p]==pos_y[0]){ if(pommex[p]==pos_x[0] && pommey[p]==pos_y[0]){
(*segment) +=2; (*segment) +=2;
pommex[p] = ((rand() % (60)+1)*20); pommex[p] = ((rand() % (53)+1)*20);
pommey[p] = ((rand() % (27)+1)*20); pommey[p] = ((rand() % (27)+1)*20);
} }
} }