2023-11-20 15:04:12 +01:00
|
|
|
#include<stdlib.h>
|
|
|
|
#include<stdio.h>
|
|
|
|
#include<graph.h>
|
|
|
|
#include<time.h>
|
|
|
|
|
|
|
|
#define H 40
|
|
|
|
#define L 60
|
|
|
|
#define DELTA 1000000L
|
|
|
|
|
|
|
|
void Affiche(int tab[H][L], int posx, int posy, int i, int j){
|
|
|
|
couleur c;
|
|
|
|
if(tab[i][j]==0){
|
|
|
|
c=CouleurParNom("green");
|
|
|
|
ChoisirCouleurDessin(c);
|
|
|
|
RemplirRectangle(posx,posy,20,20);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(tab[i][j]==1){
|
|
|
|
c=CouleurParNom("yellow");
|
|
|
|
ChoisirCouleurDessin(c);
|
|
|
|
RemplirRectangle(posx,posy,20,20);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DessinerScene(int n)
|
|
|
|
{
|
|
|
|
couleur c;
|
|
|
|
char buf[100];
|
|
|
|
c=CouleurParNom("white");
|
|
|
|
ChoisirCouleurDessin(c);
|
|
|
|
RemplirRectangle(0,850,200,100);
|
|
|
|
c=CouleurParNom("black");
|
|
|
|
ChoisirCouleurDessin(c);
|
|
|
|
snprintf(buf,100,"time : %d",n);
|
|
|
|
EcrireTexte(50,900,buf,2);
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(void){
|
|
|
|
/*partie graphique*/
|
|
|
|
InitialiserGraphique();
|
|
|
|
CreerFenetre(10,10,1700,1000);
|
|
|
|
couleur c;
|
|
|
|
c=CouleurParNom("green");
|
|
|
|
ChoisirCouleurDessin(c);
|
|
|
|
int tab[H][L];
|
2023-11-20 16:09:51 +01:00
|
|
|
int i,j,posx=0,posy=0,n=0,sxmin=1,symin=1,sxmax=10,symax=1,pause=0;
|
2023-11-20 15:04:12 +01:00
|
|
|
unsigned long suivant,suivant2;
|
2023-11-20 16:09:51 +01:00
|
|
|
suivant2=Microsecondes()+DELTA;
|
2023-11-20 15:04:12 +01:00
|
|
|
suivant=Microsecondes()+DELTA;
|
|
|
|
for(i=0;i<H;i++){
|
|
|
|
for(j=0;j<L;j++){
|
|
|
|
tab[i][j]=0;
|
|
|
|
}
|
|
|
|
}
|
2023-11-20 16:09:51 +01:00
|
|
|
|
|
|
|
/*tab[sxmin][symin]=1;*/
|
|
|
|
tab[sxmax][symax]=1;
|
|
|
|
for(i=0;i<10;i++){
|
|
|
|
tab[i][1]=1;
|
|
|
|
}
|
|
|
|
if(ToucheEnAttente()&&Touche()==XK_t){
|
|
|
|
if(pause==0){
|
|
|
|
pause=1;
|
|
|
|
}
|
|
|
|
if(pause==1){
|
|
|
|
pause=0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-20 15:04:12 +01:00
|
|
|
while(1){
|
|
|
|
if(Microsecondes()>suivant){
|
|
|
|
n++;
|
|
|
|
DessinerScene(n);
|
|
|
|
suivant=Microsecondes()+DELTA;
|
|
|
|
}
|
2023-11-20 16:09:51 +01:00
|
|
|
if(pause==0){
|
|
|
|
if(Microsecondes()>suivant2){
|
|
|
|
/*tab[sxmax][symax]=0;*/
|
|
|
|
sxmax=sxmax+1;
|
|
|
|
tab[sxmax][symax]=1;
|
|
|
|
tab[sxmin][symin]=0;
|
|
|
|
sxmin=sxmin+1;
|
|
|
|
suivant2=Microsecondes()+DELTA;
|
2023-11-20 15:04:12 +01:00
|
|
|
}
|
2023-11-20 16:09:51 +01:00
|
|
|
}
|
|
|
|
|
2023-11-20 15:04:12 +01:00
|
|
|
|
|
|
|
for(i=0;i<H;i++){
|
|
|
|
for(j=0;j<L;j++){
|
|
|
|
Affiche(tab, posx, posy, i, j);
|
|
|
|
posx=posx+20;
|
|
|
|
}
|
|
|
|
posx=0;
|
|
|
|
posy=posy+20;
|
|
|
|
}
|
|
|
|
posx=0;
|
|
|
|
posy=0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|