Commit 39758f3eaf34bc36a24bca5502e02cecc3ee5273
1 parent
dbd583f9
debut du snake 17 juin
Showing
15 changed files
with
111 additions
and
11 deletions
Show diff stats
... | ... | @@ -0,0 +1,13 @@ |
1 | +SOURCES = $(wildcard *.c) | |
2 | +OBJETS = $(SOURCES:.c=.o) | |
3 | +BIBLIOTHEQUES = -L ../Liste -lListe -L ../Graphique -lgraph | |
4 | +EXECUTABLE = centipede | |
5 | +CFLAGS += -Wall -I ../Liste -I ../Graphique | |
6 | + | |
7 | +all: $(EXECUTABLE) | |
8 | + | |
9 | +$(EXECUTABLE): $(OBJETS) | |
10 | + $(CC) -o $@ $^ $(BIBLIOTHEQUES) -lSDL | |
11 | + | |
12 | +clean: | |
13 | + rm -rf $(EXECUTABLE) *.o | ... | ... |
No preview for this file type
... | ... | @@ -0,0 +1,86 @@ |
1 | +#include <stdio.h> | |
2 | +#include <stdlib.h> | |
3 | +#include <libFile.h> | |
4 | +#include <libgraph.h> | |
5 | +#include <unistd.h> | |
6 | +#include <time.h> | |
7 | +#define MAX_ELEMENTS 50 | |
8 | + | |
9 | +typedef struct { | |
10 | + int x; | |
11 | + int y; | |
12 | +}position; | |
13 | + | |
14 | +typedef struct { | |
15 | + position contenu[MAX_ELEMENTS]; | |
16 | + int nombre; | |
17 | + } liste_champi; | |
18 | + | |
19 | +void affichage(element_t e) | |
20 | +{ | |
21 | + position *p = e; | |
22 | + printf("%d %d \n", p->x, p->y); | |
23 | +} | |
24 | + | |
25 | + | |
26 | +int main() { | |
27 | + srand(time(NULL)); | |
28 | + char touche; | |
29 | + unsigned char bas; | |
30 | + void* detail; | |
31 | + int largeur = 1000; | |
32 | + int hauteur = 1000; | |
33 | + liste_champi muschrooms={.nombre=0}; | |
34 | + int h,w,l,i; | |
35 | + char *titre = "Le Centipède"; | |
36 | + | |
37 | + creerSurface(largeur,hauteur,titre); | |
38 | + int champi = chargerLutin("Lutins/millepatte_champi.bmp",0); | |
39 | + if(champi<0){ printf("Champi pas là\n"); exit(-1); } | |
40 | + int Teted = chargerLutin("Lutins/millepatte_tete_droite.bmp",0); | |
41 | + tailleLutin(champi,&l,&h); | |
42 | + position poschampi; | |
43 | + | |
44 | + int x = (rand()%20)*50+2; | |
45 | + int y = (rand()%20)*50; | |
46 | + afficherLutin(Teted,x,y); | |
47 | + | |
48 | + for(i = 0 ; i < 20; i++) | |
49 | + { | |
50 | + rectanglePlein(i*50,0,1,1000,5); | |
51 | + rectanglePlein(0,i*50,1000,1,5); | |
52 | + } | |
53 | + | |
54 | + for(w=0;w<10;w++) { | |
55 | + poschampi.x = (rand()%20)*50; | |
56 | + poschampi.y = (rand()%20)*50; | |
57 | + muschrooms.contenu[muschrooms.nombre++]=poschampi; | |
58 | + } | |
59 | + | |
60 | + | |
61 | + | |
62 | + printf("%d %d \n",l,h); | |
63 | + | |
64 | + for(w=0;w<10;w++){ | |
65 | + afficherLutin(champi,(muschrooms.contenu[w].x)+1,(muschrooms.contenu[w].y)+6); | |
66 | + } | |
67 | + majSurface(); | |
68 | + | |
69 | + | |
70 | + | |
71 | + while(1){ | |
72 | + while(!lireTouche(&bas,&touche,&detail)); | |
73 | + printf("%d %c\n",bas,touche); | |
74 | + if(touche=='a') | |
75 | + { | |
76 | + fermerSurface(); | |
77 | + return 0; | |
78 | + | |
79 | + } | |
80 | + } | |
81 | + | |
82 | + | |
83 | + return 0; | |
84 | +} | |
85 | + | |
86 | + | |
0 | 87 | \ No newline at end of file | ... | ... |
No preview for this file type
projets/Graphique/libgraph.a
No preview for this file type
projets/Graphique/libgraph.o
No preview for this file type
projets/Liste/libFile.c
projets/Liste/libFile.h
projets/Liste/libFile.o
No preview for this file type
projets/Liste/libListe.a
No preview for this file type
projets/Makefile
1 | -REPERTOIRES = Graphique Liste Testliste | |
1 | +REPERTOIRES = Graphique Liste Testliste Centipede | |
2 | 2 | COMPILE = $(REPERTOIRES:%=all-%) |
3 | 3 | DEVERMINE = $(REPERTOIRES:%=debug-%) |
4 | 4 | NETTOYAGE = $(REPERTOIRES:%=clean-%) |
5 | -export CFLAGS += -Wall | |
5 | +export CFLAGS += -g -Wall | |
6 | 6 | |
7 | 7 | all: $(COMPILE) |
8 | 8 | $(COMPILE): | ... | ... |
projets/Testliste/projet
No preview for this file type
projets/Testliste/test.c
... | ... | @@ -17,11 +17,11 @@ enfiler(&desnombres,&moyen,sizeof(int)); |
17 | 17 | enfiler(&desnombres,&grand,sizeof(int)); |
18 | 18 | enfiler(&desnombres,&petit,sizeof(int)); |
19 | 19 | |
20 | -afficher(&desnombres,affichage); | |
20 | +//afficher(&desnombres,affichage); | |
21 | 21 | |
22 | -defiler(&desnombres); | |
22 | +//defiler(&desnombres); | |
23 | 23 | |
24 | -afficher(&desnombres,affichage); | |
24 | +//afficher(&desnombres,affichage); | |
25 | 25 | |
26 | 26 | return 0; |
27 | 27 | } | ... | ... |
projets/Testliste/test.o
No preview for this file type