1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
void bouger_kompa_vert(int carte[][NB_BLOCS_HAUTEUR],int *direction,SDL_Rect *position)
{
switch(*direction)
{
printf("y");
direction = GAUCHE;
case GAUCHE:
if(carte[position->x][position->y + 1] == MUR)
{
if(carte[position->x - 1][position->y + 1] == VIDE)
{
*direction = DROITE; // on change de direction
}
else
{
carte[position->x - 1][position->y] = MONSTRE1;
carte[position->x][position->y] = VIDE;
}
}
break;
case DROITE:
if(carte[position->x][position->y + 1] == MUR) // sous nos pied il y a un mur
{
if(carte[position->x + 1][position->y + 1] == VIDE)
{
printf("o");
*direction = GAUCHE; // on change de direction
}
else
{
printf("8");
carte[position->x + 1][position->y] = MONSTRE1;
carte[position->x][position->y] = VIDE;
}
}
break;
}
} |