Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include "game.h"
- int Afficher_Tableau(int tableau[TAILLE_RANGEE][TAILLE_COLONNE])
- {
- int i=0, j=0;
- for(i=0;i<TAILLE_RANGEE;i++)
- for(j=0;j<TAILLE_COLONNE;j++)
- {
- if (tableau[i][j]==1)
- printf("T");
- if (tableau[i][j]==0)
- printf(" ");
- if (tableau[i][j]==2)
- {
- if (j<TAILLE_COLONNE-1)
- printf("O");
- else
- printf("O\n");
- }
- }
- }
- int Deplacer_T(int tableau[TAILLE_RANGEE][TAILLE_COLONNE])
- {
- char deplacer='a';
- while (deplacer!='q')
- {
- Afficher_Tableau(tableau);
- printf("\n\n");
- printf("(d)roite, (g)auche ou (q)itter, (b)as ou (h)aut : ");
- scanf("%s", &deplacer);
- switch(deplacer)
- {
- case 'q':
- break;
- case 'd':
- deplacer_droite(tableau);
- break;
- case 'g':
- deplacer_gauche(tableau);
- break;
- case 'b':
- deplacer_bas(tableau);
- break;
- case 'h':
- deplacer_haut(tableau);
- break;
- }
- }
- }
- void deplacer_droite(int tableau[TAILLE_RANGEE][TAILLE_COLONNE])
- {
- int i=0, j=0;
- for(i=1;i<(TAILLE_RANGEE-1);i++)
- {
- if (tableau[i][TAILLE_COLONNE-2]==1)
- { printf("\nTU NE PEUX PAS SORTIR DU CARDRE !!!\n");
- break;
- }
- for(j=1;j<(TAILLE_COLONNE-2);j++)
- {
- if (tableau[i][j]==1)
- {
- tableau[i][j]=0;
- tableau[i][j+1]=1;
- break;
- }
- }
- }
- }
- void deplacer_gauche(int tableau[TAILLE_RANGEE][TAILLE_COLONNE])
- {
- int i=0, j=0;
- for(i=1;i<(TAILLE_RANGEE-1);i++)
- {
- if (tableau[i][1]==1)
- { printf("\nTU NE PEUX PAS SORTIR DU CARDRE !!!\n");
- break;
- }
- for(j=2;j<(TAILLE_COLONNE-1);j++)
- {
- if (tableau[i][j]==1)
- {
- tableau[i][j]=0;
- tableau[i][j-1]=1;
- break;
- }
- }
- }
- }
- void deplacer_bas(int tableau[TAILLE_RANGEE][TAILLE_COLONNE])
- {
- int i=0, j=0;
- for(j=1;j<(TAILLE_COLONNE-1);j++)
- {
- if (tableau[TAILLE_RANGEE-2][j]==1)
- { printf("\nTU NE PEUX PAS SORTIR DU CARDRE !!!\n");
- break;
- }
- for(i=1;i<(TAILLE_RANGEE-2);i++)
- {
- if (tableau[i][j]==1)
- {
- tableau[i][j]=0;
- tableau[i+1][j]=1;
- break;
- }
- }
- }
- }
- void deplacer_haut(int tableau[TAILLE_RANGEE][TAILLE_COLONNE])
- {
- int i=0, j=0;
- for(j=1;j<(TAILLE_COLONNE-1);j++)
- {
- if (tableau[1][j]==1)
- { printf("\nTU NE PEUX PAS SORTIR DU CARDRE !!!\n");
- break;
- }
- for(i=2;i<(TAILLE_RANGEE-1);i++)
- {
- if (tableau[i][j]==1)
- {
- tableau[i][j]=0;
- tableau[i-1][j]=1;
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement