le tirage aleatoire fonctionne

This commit is contained in:
Mathieu PROAL 2022-11-28 18:34:21 +01:00
parent 12166505f6
commit 1f536a6c35
3 changed files with 40 additions and 9 deletions

View File

@ -3,5 +3,9 @@
#include <graph.h>
#include <time.h>
#include "images.h"
#include "action.h"
int main(void){
tirage_aleatoire();
return EXIT_SUCCESS;
}

View File

@ -4,26 +4,30 @@
#include <time.h>
#include "images.h"
int tirage_aleatoire(void){
int main(void){
InitialiserGraphique();
ChoisirEcran(0);
CreerFenetre(0,0,1024,576);
char tirage[50];
int pos_x, pos_y;
int pos_x, pos_y, clic_x, clic_y, spr, spr2;
int i, j;
int nb;
int tab[40];
int nb_paires;
printf("Combien de paires ? --> ");
scanf("%d", &nb_paires);
int nb_paires=20;
int positions[20][4];
ChargerImage("Images/background.png",0,0,0,0,1024,576);
/*Initialisation des tableaux*/
for (i=0;i<20;i++){
for (j=0;j<2;j++){
positions[i][j]=0;
}
for (i=0;i<40;i++){
tab[i]=0;
}
/*Tirage des images*/
srand(time(NULL));
for (i=0;i<2;i++){
for (j=0;j<nb_paires+1;j++){
@ -38,7 +42,7 @@ int tirage_aleatoire(void){
}
/*Tirage des images*/
/*Affichage des images*/
srand(time(NULL));
i=0;
for (pos_y=10;pos_y<380;pos_y=pos_y+90){
@ -46,17 +50,40 @@ int tirage_aleatoire(void){
if (tab[i]==0){
pos_y=1000;
}
if (positions[tab[i]][0]==0){
positions[tab[i]][0]=pos_x;
positions[tab[i]][1]=pos_y;
}
else{
positions[tab[i]][2]=pos_x;
positions[tab[i]][3]=pos_y;
}
snprintf(tirage,50,"Images/image%d.png",tab[i]);
ChargerImage(tirage,pos_x,pos_y,0,0,80,80);
i++;
}
}
/*SourisCliquee();
clic_x=_X;
clic_y=_Y;*/
spr = ChargerSprite("Images/image0.png");
AfficherSprite(spr, 10, 10);
Touche();
LibererSprite(spr);
spr2= ChargerSprite("Images/image0.png");
AfficherSprite(spr, 100, 100);
Touche();
printf("%d", spr2);
Touche();
FermerGraphique();
printf("\n");
return EXIT_SUCCESS;
}
}

View File

@ -1,6 +1,6 @@
#ifndef IMAGES_H
#define IMAGES_H
void chargement(void);
int tirage_aleatoire(void);
#endif