ajout rectification makefile + struct pixel

This commit is contained in:
2023-12-03 14:16:38 +01:00
parent b76b89f890
commit f8d4e822f1
6 changed files with 110 additions and 83 deletions

View File

@@ -2,6 +2,7 @@
#include <stdio.h>
#include <stdlib.h>
#include "main.h"
#include <time.h>
void AfficherTimerEtScore(int m,int n,int score) /*Afficher le temps passé et le score*/
@@ -21,18 +22,41 @@ void AfficherTimerEtScore(int m,int n,int score) /*Afficher le temps passé et
CopierZone(1,0,0,0,930,710,0,0);
}
void InitialiserPastilles(PIXELS *pastilles) {
int i;
couleur r;
void MangerPastille(int *serpent, int* pastilles, int longueur_serpent, int longueur_pastilles)
r = CouleurParNom("red");
ChoisirCouleurDessin(r);
srand(time(NULL));
for (i = 0; i < PASTILLES; i++) {
pastilles[i] = gen_pastille();
RemplirRectangle(pastilles[i].x,pastilles[i].y,T_PIXEL,T_PIXEL);
}
}
void MangerPastille(int *serpent, PIXELS* pastilles, int longueur_serpent, int longueur_pastilles)
{
couleur r;
int i = 0;
for(i=0;i<longueur_pastilles;i+=2)
r = CouleurParNom("red");
ChoisirCouleurDessin(r);
for(i=0;i<PASTILLES;i++)
{
if(serpent[0] == pastilles[i] && serpent[1] == pastilles[i+1])
if(serpent[0] == pastilles[i].x && serpent[1] == pastilles[i].y)
{
printf("\nMANGER !\n");
pastilles[i] = gen_pastille();
RemplirRectangle(pastilles[i].x,pastilles[i].y,T_PIXEL,T_PIXEL);
}
}
}
@@ -64,27 +88,22 @@ void DeplacementSerpent(int direction ,int *serpent, int longueur)
ChoisirCouleurDessin(j);
if(direction == 0) /* Direction vers la gauche */
{
printf("Gauche %d\n",direction);
serpent[0]-=T_PIXEL;
RemplirRectangle(serpent[0],serpent[1],T_PIXEL,T_PIXEL);
printf("Longueur = %d | x %d | y %d",longueur,serpent[longueur-1],serpent[longueur-2]);
}
else if(direction == 1) /* Direction vers le haut */
{
printf("Haut %d\n",direction);
serpent[1]-=T_PIXEL;
RemplirRectangle(serpent[0],serpent[1],T_PIXEL,T_PIXEL);
}
else if(direction == 2) /* Direction vers la droite */
{
printf("Droite %d\n",direction);
serpent[0]+=T_PIXEL;
RemplirRectangle(serpent[0],serpent[1],T_PIXEL,T_PIXEL);
}
else if(direction == 3) /* Direction vers le bas */
{
printf("Bas %d\n",direction);
serpent[1]+=T_PIXEL;
RemplirRectangle(serpent[0],serpent[1],T_PIXEL,T_PIXEL);
}