Amelioration code + commentaires. Rectifications erreurs etc.

This commit is contained in:
Vincent
2023-12-24 01:48:21 +01:00
parent 494177f3c1
commit d34541178a
9 changed files with 232 additions and 46 deletions

50
scene.c
View File

@@ -29,7 +29,18 @@ PIXELS gen_pastille(PIXELS *serpent,PIXELS *pastilles,PIXELS *obstacle,unsigned
ok = 0;
x_pastille= ArrondirPixel(rand()%W_GAME);
y_pastille = ArrondirPixel(rand()%H_GAME);
for(i=0;i<longueur_serpent;i++)
if(x_pastille < DECALEMENT)
{
x_pastille =+ DECALEMENT;
}
if(y_pastille < DECALEMENT)
{
y_pastille =+ DECALEMENT;
}
for(i=0;i<=longueur_serpent;i++)
{
if(x_pastille == serpent[i].x && y_pastille == serpent[i].y)
{
@@ -41,7 +52,7 @@ PIXELS gen_pastille(PIXELS *serpent,PIXELS *pastilles,PIXELS *obstacle,unsigned
}
}
for(i=0;i<longueur_obstacle;i++)
for(i=0;i<=longueur_obstacle;i++)
{
if(x_pastille == obstacle[i].x && y_pastille == obstacle[i].y)
{
@@ -55,16 +66,6 @@ PIXELS gen_pastille(PIXELS *serpent,PIXELS *pastilles,PIXELS *obstacle,unsigned
}
}while(ok);
if(x_pastille < DECALEMENT)
{
x_pastille =+ DECALEMENT;
}
if(y_pastille < DECALEMENT)
{
y_pastille =+ DECALEMENT;
}
pastille.x = x_pastille ;
pastille.y = y_pastille ;
@@ -85,7 +86,18 @@ PIXELS gen_obstacle(PIXELS *serpent,PIXELS *pastilles,PIXELS *obstacle,unsigned
ok = 0;
x_obstacles= ArrondirPixel(rand()%W_GAME);
y_obstacles = ArrondirPixel(rand()%H_GAME);
for(i=0;i<longueur_serpent;i++)
if(x_obstacles < DECALEMENT)
{
x_obstacles =+ DECALEMENT;
}
if(y_obstacles < DECALEMENT)
{
y_obstacles =+ DECALEMENT;
}
for(i=0;i<=longueur_serpent;i++)
{
if(x_obstacles == serpent[i].x && y_obstacles == serpent[i].y)
{
@@ -97,7 +109,7 @@ PIXELS gen_obstacle(PIXELS *serpent,PIXELS *pastilles,PIXELS *obstacle,unsigned
}
}
for(i=0;i<longueur_pastilles;i++)
for(i=0;i<=longueur_pastilles;i++)
{
if(x_obstacles == pastilles[i].x && y_obstacles == pastilles[i].y)
{
@@ -111,16 +123,6 @@ PIXELS gen_obstacle(PIXELS *serpent,PIXELS *pastilles,PIXELS *obstacle,unsigned
}
}while(ok);
if(x_obstacles < DECALEMENT)
{
x_obstacles =+ DECALEMENT;
}
if(y_obstacles < DECALEMENT)
{
y_obstacles =+ DECALEMENT;
}
obstacles.x = x_obstacles ;
obstacles.y = y_obstacles ;