diff --git a/DEV1.1/TP13/exercices_cercles.png b/DEV1.1/TP13/exercices_cercles.png new file mode 100644 index 0000000..4713bcc Binary files /dev/null and b/DEV1.1/TP13/exercices_cercles.png differ diff --git a/DEV1.1/TP13/fenetre.c b/DEV1.1/TP13/fenetre.c new file mode 100644 index 0000000..16d63ad --- /dev/null +++ b/DEV1.1/TP13/fenetre.c @@ -0,0 +1,16 @@ +#include +#include +#include + +int main(int argc, char const *argv[]) +{ + InitialiserGraphique(); + CreerFenetre(10,10,480,270); + while(!SourisCliquee()); + FermerGraphique(); + + return 0; + + + +} \ No newline at end of file diff --git a/DEV1.1/TP13/formes.c b/DEV1.1/TP13/formes.c new file mode 100644 index 0000000..2f5b903 --- /dev/null +++ b/DEV1.1/TP13/formes.c @@ -0,0 +1,64 @@ +#include +#include +#include + +void carre(int x,int y) +{ + DessinerSegment(x-25,y-25,x+25,y-25); + DessinerSegment(x+25,y-25,x+25,y+25); + DessinerSegment(x+25,y+25,x-25,y+25); + DessinerSegment(x-25,y+25,x-25,y-25); +} + +void cercle(int x,int y) +{ + couleur c; + c=CouleurParComposante(0,255,0); + ChoisirCouleurDessin(c); + RemplirArc(x-30,y-30,60,60,0,360); +} + +void txtface(int x, int y) +{ + couleur c; + c=CouleurParComposante(255,0,255); + ChoisirCouleurDessin(c); + EcrireTexte(x-25,y+7,">o<",2); +} + + + + +int main(int argc, char const *argv[]) +{ + InitialiserGraphique(); + CreerFenetre(10,10,480,270); + int touche; + while(touche!=XK_space) + { + touche=Touche(); + SourisPosition(); + if(touche==XK_a) + { + carre(_X,_Y); + } + if(touche==XK_z) + { + cercle(_X,_Y); + } + if(touche==XK_e) + { + txtface(_X,_Y); + } + if(touche==XK_r) + { + ChargerImage("exercices_cercles.png",_X-45,_Y+15,0,0,103,36); + } + } + FermerGraphique(); + + return 0; + + + +} \ No newline at end of file diff --git a/DEV1.1/random/ttt.c b/DEV1.1/random/ttt.c new file mode 100644 index 0000000..b4b8e5d --- /dev/null +++ b/DEV1.1/random/ttt.c @@ -0,0 +1,98 @@ +#include +#include +#include + +void Croix(int c,int l) +{ + DessinerSegment(20+300*c,20+300*l,280+300*c,280+300*l); + DessinerSegment(280+300*c,20+300*l,20+300*c,280+300*l); + return; +} + +void Cercle(int c, int l) +{ + DessinerArc(300*c+20,300*l+20,260,260,0,360); + return; +} + +int victoire(int tab[3][3]) +{ + int full=0; + for(int i=0;i<3;i++) + { + for(int j=0;j<3;j++) + if (tab[i][j]==0) + { + full++; + } + } + for(int i=0;i<3;i++) + { + if (tab[i][0]==tab[i][1]&&tab[i][1]==tab[i][2]) + { + if (tab[i][0]!=0) + { + return(1); + } + } + } + if (full==9) + { + return(-1); + } + else{return(0);} +} + +int main(int argc, char const *argv[]) +{ + int x=_X; + int y=_Y; + + InitialiserGraphique(); + CreerFenetre(10,10,900,900); + DessinerSegment(300,0,300,900); + DessinerSegment(600,0,600,900); + DessinerSegment(0,300,900,300); + DessinerSegment(0,600,900,600); + int l,c; + int tab[3][3]={0}; + int tour=1; + int vic=0; + while(vic==0) + { + while(!SourisCliquee()); + l=_Y/300; + c=_X/300; + if (tab[c][l]==0) + { + if ((tour%2)==0) + { + Croix(c,l); + tab[c][l]=1; + } + else + { + Cercle(c,l); + tab[c][l]=2; + } + tour++; + } + vic=victoire(tab); + } + + if (vic==-1) + { + printf("Egalité !"); + } + if (vic=1&&(tour%2)==0) + { + printf("Victoire Croix !"); + }else{ + printf("Victoire Cercle !"); + } + + + Touche(); + FermerGraphique(); + return 0; +} \ No newline at end of file