From 39758f3eaf34bc36a24bca5502e02cecc3ee5273 Mon Sep 17 00:00:00 2001 From: Pierre Cwik Date: Fri, 17 Jun 2016 18:00:09 +0200 Subject: [PATCH] debut du snake 17 juin --- projets/Centipede/Makefile | 13 +++++++++++++ projets/Centipede/centipede | Bin 0 -> 27992 bytes projets/Centipede/progprinc.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ projets/Centipede/progprinc.o | Bin 0 -> 6680 bytes projets/Graphique/libgraph.a | Bin 7662 -> 0 bytes projets/Graphique/libgraph.o | Bin 7288 -> 0 bytes projets/Liste/.directory | 6 ++++++ projets/Liste/libFile.c | 6 +----- projets/Liste/libFile.h | 1 - projets/Liste/libFile.o | Bin 2584 -> 0 bytes projets/Liste/libListe.a | Bin 2778 -> 0 bytes projets/Makefile | 4 ++-- projets/Testliste/projet | Bin 8288 -> 0 bytes projets/Testliste/test.c | 6 +++--- projets/Testliste/test.o | Bin 1816 -> 0 bytes 15 files changed, 111 insertions(+), 11 deletions(-) create mode 100644 projets/Centipede/Makefile create mode 100755 projets/Centipede/centipede create mode 100644 projets/Centipede/progprinc.c create mode 100644 projets/Centipede/progprinc.o create mode 100644 projets/Liste/.directory diff --git a/projets/Centipede/Makefile b/projets/Centipede/Makefile new file mode 100644 index 0000000..6b28b6e --- /dev/null +++ b/projets/Centipede/Makefile @@ -0,0 +1,13 @@ +SOURCES = $(wildcard *.c) +OBJETS = $(SOURCES:.c=.o) +BIBLIOTHEQUES = -L ../Liste -lListe -L ../Graphique -lgraph +EXECUTABLE = centipede +CFLAGS += -Wall -I ../Liste -I ../Graphique + +all: $(EXECUTABLE) + +$(EXECUTABLE): $(OBJETS) + $(CC) -o $@ $^ $(BIBLIOTHEQUES) -lSDL + +clean: + rm -rf $(EXECUTABLE) *.o diff --git a/projets/Centipede/centipede b/projets/Centipede/centipede new file mode 100755 index 0000000..8a24682 Binary files /dev/null and b/projets/Centipede/centipede differ diff --git a/projets/Centipede/progprinc.c b/projets/Centipede/progprinc.c new file mode 100644 index 0000000..838af95 --- /dev/null +++ b/projets/Centipede/progprinc.c @@ -0,0 +1,86 @@ +#include +#include +#include +#include +#include +#include +#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; +} + + \ No newline at end of file diff --git a/projets/Centipede/progprinc.o b/projets/Centipede/progprinc.o new file mode 100644 index 0000000..0f3f838 Binary files /dev/null and b/projets/Centipede/progprinc.o differ diff --git a/projets/Graphique/libgraph.a b/projets/Graphique/libgraph.a index 7d60157..7833a2d 100644 Binary files a/projets/Graphique/libgraph.a and b/projets/Graphique/libgraph.a differ diff --git a/projets/Graphique/libgraph.o b/projets/Graphique/libgraph.o index a156c1f..3d91fea 100644 Binary files a/projets/Graphique/libgraph.o and b/projets/Graphique/libgraph.o differ diff --git a/projets/Liste/.directory b/projets/Liste/.directory new file mode 100644 index 0000000..e8d027c --- /dev/null +++ b/projets/Liste/.directory @@ -0,0 +1,6 @@ +[Dolphin] +Timestamp=2016,6,17,14,20,55 +Version=3 + +[Settings] +HiddenFilesShown=true diff --git a/projets/Liste/libFile.c b/projets/Liste/libFile.c index e8dc8ae..c1b0b72 100644 --- a/projets/Liste/libFile.c +++ b/projets/Liste/libFile.c @@ -20,11 +20,7 @@ l->contenu[l->nombre++]=nouveau; return 0; } -void affichage(element_t e) -{ - liste_t *l=e; - printf("%d",l->contenu); -} + int afficher(liste_t *l, void(*affichage)(element_t)) { int i; diff --git a/projets/Liste/libFile.h b/projets/Liste/libFile.h index ea924ff..df7dfb9 100644 --- a/projets/Liste/libFile.h +++ b/projets/Liste/libFile.h @@ -10,4 +10,3 @@ int taille(liste_t *l); int enfiler (liste_t *l, element_t e, int taille); int afficher (liste_t *l, void(*affichage)(element_t)); int defiler(liste_t *l); -void affichage(element_t e); diff --git a/projets/Liste/libFile.o b/projets/Liste/libFile.o index 2bd4188..d18b9be 100644 Binary files a/projets/Liste/libFile.o and b/projets/Liste/libFile.o differ diff --git a/projets/Liste/libListe.a b/projets/Liste/libListe.a index 99cdace..6195863 100644 Binary files a/projets/Liste/libListe.a and b/projets/Liste/libListe.a differ diff --git a/projets/Makefile b/projets/Makefile index 0ca8ef6..ea5eae2 100644 --- a/projets/Makefile +++ b/projets/Makefile @@ -1,8 +1,8 @@ -REPERTOIRES = Graphique Liste Testliste +REPERTOIRES = Graphique Liste Testliste Centipede COMPILE = $(REPERTOIRES:%=all-%) DEVERMINE = $(REPERTOIRES:%=debug-%) NETTOYAGE = $(REPERTOIRES:%=clean-%) -export CFLAGS += -Wall +export CFLAGS += -g -Wall all: $(COMPILE) $(COMPILE): diff --git a/projets/Testliste/projet b/projets/Testliste/projet index da2800b..fc98fda 100755 Binary files a/projets/Testliste/projet and b/projets/Testliste/projet differ diff --git a/projets/Testliste/test.c b/projets/Testliste/test.c index c8e54b3..ccb65fc 100644 --- a/projets/Testliste/test.c +++ b/projets/Testliste/test.c @@ -17,11 +17,11 @@ enfiler(&desnombres,&moyen,sizeof(int)); enfiler(&desnombres,&grand,sizeof(int)); enfiler(&desnombres,&petit,sizeof(int)); -afficher(&desnombres,affichage); +//afficher(&desnombres,affichage); -defiler(&desnombres); +//defiler(&desnombres); -afficher(&desnombres,affichage); +//afficher(&desnombres,affichage); return 0; } diff --git a/projets/Testliste/test.o b/projets/Testliste/test.o index 8f431d5..cee60ab 100644 Binary files a/projets/Testliste/test.o and b/projets/Testliste/test.o differ -- libgit2 0.21.2