Améliorations Visuels

This commit is contained in:
2023-12-18 15:21:28 +01:00
parent 1eedd2c4e2
commit 7c0621f36a
3 changed files with 50 additions and 81 deletions

View File

@@ -4,7 +4,6 @@
#include "main.h"
#include <time.h>
void AfficherTimerEtScore(long unsigned int *score, int minutes,int secondes) /*Afficher le temps passé et le score*/
{
char buf[100];
@@ -27,10 +26,6 @@ void AfficherTimerEtScore(long unsigned int *score, int minutes,int secondes)
void InitialiserPastilles(PIXELS *pastilles, PIXELS *serpent, int longueur_serpent) {
int i;
couleur r;
r = CouleurParNom("red");
ChoisirCouleurDessin(r);
srand(time(NULL));
@@ -57,12 +52,9 @@ int MourrirSerpent(PIXELS *serpent, int longueur_serpent)
return 0;
}
int MangerPastille(PIXELS *serpent, PIXELS* pastilles,unsigned long *score,int longueur_serpent)
int MangerPastille(PIXELS *serpent, PIXELS* pastilles,unsigned long *score,int longueur_serpent,unsigned long int *vitesse)
{
couleur r;
int i = 0;
r = CouleurParNom("red");
ChoisirCouleurDessin(r);
for(i=0;i<PASTILLES;i++)
{
if(serpent[0].x == pastilles[i].x && serpent[0].y == pastilles[i].y)
@@ -70,41 +62,33 @@ int MangerPastille(PIXELS *serpent, PIXELS* pastilles,unsigned long *score,int l
pastilles[i] = gen_pastille(serpent,pastilles,longueur_serpent);
ChargerImage("./images/PommePastille.png",pastilles[i].x,pastilles[i].y,0,0,T_PIXEL,T_PIXEL);
*score+=5;
*vitesse/=1.008;
return 1;
}
}
return 0;
}
/*int PastilleSurSerpent(PIXELS pastille, int *serpent, size_t longueur_serpent)
{
int i;
for(i=0;i<longueur_serpent;i+=2)
{
if (pastille.x==serpent[i] && pastille.y ==serpent[i+1])
{
return 1;
}
}
return 0;
}*/
void DeplacementSerpent(int direction ,PIXELS *serpent, int longueur)
{
int tempX = serpent[0].x;
int tempY = serpent[0].y;
int i;
couleur g;
couleur j;
couleur bg;
ChoisirEcran(2);
j=CouleurParNom("yellow");
g=CouleurParComposante(171, 204, 104);
bg=CouleurParComposante(171, 204, 104);
ChoisirCouleurDessin(bg);
if(serpent[longueur-1].x > 900 || serpent[longueur-1].x < 0)
{
serpent[longueur-1].x = 30;
serpent[longueur-1].y = 710; /* Valeurs toujours de couleurs verte */
}
RemplirRectangle(serpent[longueur-1].x,serpent[longueur-1].y,T_PIXEL,T_PIXEL);
for (i = 1; i < longueur; i++) {
for (i = 1; i <= longueur; i++) {
int tempX2 = serpent[i].x;
int tempY2 = serpent[i].y;
@@ -113,15 +97,8 @@ void DeplacementSerpent(int direction ,PIXELS *serpent, int longueur)
tempX = tempX2;
tempY = tempY2;
if(i == longueur-1)
{
ChoisirCouleurDessin(g);
RemplirRectangle(serpent[i].x,serpent[i].y,T_PIXEL,T_PIXEL);
}
}
ChoisirCouleurDessin(j);
if(direction == 0) /* Direction vers la gauche */
{
serpent[0].x-=T_PIXEL;
@@ -131,7 +108,6 @@ void DeplacementSerpent(int direction ,PIXELS *serpent, int longueur)
{
serpent[0].y-=T_PIXEL;
ChargerImage("./images/SnakePart.png",serpent[0].x,serpent[0].y,0,0,T_PIXEL,T_PIXEL);
}
else if(direction == 2) /* Direction vers la droite */
{