This commit is contained in:
Simon SAYE BABU 2022-11-30 15:29:10 +01:00
parent bfa9db0ea8
commit d5a3d1d6b9
4 changed files with 178 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

16
DEV1.1/TP13/fenetre.c Normal file
View File

@ -0,0 +1,16 @@
#include <graph.h>
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char const *argv[])
{
InitialiserGraphique();
CreerFenetre(10,10,480,270);
while(!SourisCliquee());
FermerGraphique();
return 0;
}

64
DEV1.1/TP13/formes.c Normal file
View File

@ -0,0 +1,64 @@
#include <graph.h>
#include <stdlib.h>
#include <stdio.h>
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;
}

98
DEV1.1/random/ttt.c Normal file
View File

@ -0,0 +1,98 @@
#include <stdlib.h>
#include <graph.h>
#include <stdio.h>
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;
}