ajout : timer
This commit is contained in:
parent
6e4db04e66
commit
19a84426a3
12
exemple.c
12
exemple.c
@ -1,12 +0,0 @@
|
||||
#include<stdlib.h>
|
||||
#include<graph.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
InitialiserGraphique();
|
||||
CreerFenetre(10,10,500,500);
|
||||
EcrireTexte(10,100,"Hello World !",2);
|
||||
Touche();
|
||||
FermerGraphique();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
BIN
souris_test
BIN
souris_test
Binary file not shown.
@ -1,33 +0,0 @@
|
||||
#include <graph.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define tx 300
|
||||
#define ty 300
|
||||
|
||||
int main(void){
|
||||
char t[50];
|
||||
int x,y;
|
||||
couleur c;
|
||||
|
||||
InitialiserGraphique();
|
||||
CreerFenetre(100,100,tx,ty);
|
||||
c=CouleurParNom("black");
|
||||
SourisPosition();
|
||||
x=_X;
|
||||
y=_Y;
|
||||
sprintf(t,"x=%3d:y=%3d",_X,_Y);
|
||||
EffacerEcran(CouleurParNom("white"));
|
||||
EcrireTexteC((tx-TailleChaineEcran(t,0))/2,ty/2,t,c,0);
|
||||
|
||||
while(!SourisCliquee()){
|
||||
SourisPosition();
|
||||
if(_X!=x||_Y!=y){
|
||||
sprintf(t,"x=%3d:y=%3d",_X,_Y);
|
||||
EffacerEcran(CouleurParNom("white"));
|
||||
EcrireTexteC((tx-TailleChaineEcran(t,0))/2,ty/2,t,c,0);
|
||||
x=_X;
|
||||
y=_Y;
|
||||
}
|
||||
}
|
||||
FermerGraphique();
|
||||
}
|
63
test.c
63
test.c
@ -1,63 +0,0 @@
|
||||
#include <stdlib.h>
|
||||
#include <graph.h>
|
||||
|
||||
void DessinerGrille(int x_g, int y_g, int x_fen, int y_fen, int triche){
|
||||
int i,j;
|
||||
int tab[2][2] = {{1,2},{1,2}};
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int l_case = (x_fen-((10*x_g)+10))/x_g;
|
||||
int h_case = (y_fen-((10*y_g)+10))/y_g;
|
||||
if (triche == 0){
|
||||
for(i=10;i<x_fen-10;i+=l_case+10){
|
||||
for(j=10;j<y_fen-10;j+=h_case+10){
|
||||
RemplirRectangle(i,j,l_case,h_case);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (triche == 1){
|
||||
for(i=10;i<x_fen-10;i+=l_case+10){
|
||||
for(j=10;j<y_fen-10;j+=h_case+10){
|
||||
ChoisirCouleurDessin((tab[x][y]*100)+100);
|
||||
RemplirRectangle(i,j,l_case,h_case);
|
||||
y++;
|
||||
}
|
||||
x++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(void){
|
||||
int tab[2][2] = {{1,2},{1,2}};
|
||||
int i,j;
|
||||
int x=1;
|
||||
int touche;
|
||||
InitialiserGraphique();
|
||||
CreerFenetre(10,10,1000,1000);
|
||||
ChoisirCouleurDessin(CouleurParComposante(0,0,0));
|
||||
DessinerGrille(2,2,1000,1000,0);
|
||||
while(1){
|
||||
if (ToucheEnAttente()){
|
||||
touche = Touche();
|
||||
if (touche == XK_t)
|
||||
x = -x;
|
||||
if (x==-1){
|
||||
EffacerEcran(CouleurParComposante(255,255,255));
|
||||
ChoisirCouleurDessin(CouleurParComposante(255,0,0));
|
||||
EcrireTexte(10,10,"mode triche",2);
|
||||
DessinerGrille(2,2,1000,1000,1);
|
||||
}
|
||||
if (x==1){
|
||||
EffacerEcran(CouleurParComposante(255,255,255));
|
||||
ChoisirCouleurDessin(CouleurParComposante(0,0,0));
|
||||
DessinerGrille(2,2,1000,1000,0);
|
||||
}
|
||||
if (touche == XK_space)
|
||||
break;
|
||||
touche = 0;
|
||||
}
|
||||
}
|
||||
FermerGraphique();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
39
timer.c
Normal file
39
timer.c
Normal file
@ -0,0 +1,39 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <graph.h>
|
||||
|
||||
int main(void){
|
||||
unsigned long temps_ecoule = 0;
|
||||
unsigned long temps = Microsecondes();
|
||||
int timer;
|
||||
int seconde_passee;
|
||||
int minutes = 0;
|
||||
int secondes = 0;
|
||||
int a = 1;
|
||||
int temps_reference = 0;
|
||||
char afficher_temps[20];
|
||||
|
||||
InitialiserGraphique();
|
||||
CreerFenetre(10,10,1500,844);
|
||||
while(a==1){
|
||||
temps_ecoule = (int) (Microsecondes() - temps);
|
||||
if (temps_reference<temps_ecoule){
|
||||
temps_reference +=1;
|
||||
timer = (int) (temps_ecoule / 1000000);
|
||||
if (timer != seconde_passee){
|
||||
seconde_passee = timer;
|
||||
secondes = timer ;
|
||||
if (secondes > 59){
|
||||
minutes = secondes/60 ;
|
||||
secondes = secondes - (minutes*60);
|
||||
}
|
||||
EffacerEcran(CouleurParNom("white"));
|
||||
ChoisirCouleurDessin(CouleurParNom("black"));
|
||||
snprintf(afficher_temps,15,"Time : %02d : %02d",minutes,secondes);
|
||||
EcrireTexte(700,50,afficher_temps,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user