progprinc.c
1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include <stdio.h>
#include <stdlib.h>
#include <libFile.h>
#include <libgraph.h>
#include <unistd.h>
#include <time.h>
#define MAX_ELEMENTS 50
typedef struct {
int x;
int y;
}position;
typedef struct {
position contenu[MAX_ELEMENTS];
int nombre;
} liste_champi;
void affichage(element_t e)
{
position *p = e;
printf("%d %d \n", p->x, p->y);
}
int main() {
srand(time(NULL));
char touche;
unsigned char bas;
void* detail;
int largeur = 1000;
int hauteur = 1000;
liste_champi muschrooms={.nombre=0};
int h,w,l,i;
char *titre = "Le Centipède";
creerSurface(largeur,hauteur,titre);
int champi = chargerLutin("Lutins/millepatte_champi.bmp",0);
if(champi<0){ printf("Champi pas là\n"); exit(-1); }
int Teted = chargerLutin("Lutins/millepatte_tete_droite.bmp",0);
tailleLutin(champi,&l,&h);
position poschampi;
int x = (rand()%20)*50+2;
int y = (rand()%20)*50;
afficherLutin(Teted,x,y);
for(i = 0 ; i < 20; i++)
{
rectanglePlein(i*50,0,1,1000,5);
rectanglePlein(0,i*50,1000,1,5);
}
for(w=0;w<10;w++) {
poschampi.x = (rand()%20)*50;
poschampi.y = (rand()%20)*50;
muschrooms.contenu[muschrooms.nombre++]=poschampi;
}
printf("%d %d \n",l,h);
for(w=0;w<10;w++){
afficherLutin(champi,(muschrooms.contenu[w].x)+1,(muschrooms.contenu[w].y)+6);
}
majSurface();
while(1){
while(!lireTouche(&bas,&touche,&detail));
printf("%d %c\n",bas,touche);
if(touche=='a')
{
fermerSurface();
return 0;
}
}
return 0;
}