diff --git a/README.md b/README.md index 7fafd5763d885cbd4c3d163be8dd621623eb8f34..bc2d133c85951c6670da2aba4f41cf684f303864 100644 --- a/README.md +++ b/README.md @@ -13,11 +13,13 @@ Trello : https://trello.com/b/YGhNeYX3/projet-apprentissage-par-renforcement ## Architecture du git ``` ├── travail_individuel - ├── Belkhiri - ├── Beret - └── Meyer - └── x_fenetre -├── travail_de_groupe +│ ├── Belkhiri +│ │ ├── x_fenetre +│ │ └── snakes +│ ├── Beret +│ └── Meyer +│ └── x_fenetre +└── travail_de_groupe ├── chef_oeuvre └── jeu_appren_par_renfo ``` diff --git a/travail_individuel/Belkhiri/snakes/Makefile b/travail_individuel/Belkhiri/snakes/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..e76de77896acfdf5d8d8e97b8a1c9504c2364375 --- /dev/null +++ b/travail_individuel/Belkhiri/snakes/Makefile @@ -0,0 +1,21 @@ +CC=gcc + +LDFLAG=$(shell sdl2-config --cflags --libs) -lm -lSDL2_ttf -D_REENTRANT -lSDL2_image -pthread +CFLAG=-Wall $(shell sdl2-config --cflags --libs) + +EXEC=run +SRC=$(wildcard *.c) +OBJ=$(SRC:.c=.o) + +all:$(EXEC) + +$(EXEC):$(OBJ) + $(CC) -o $@ $^ $(LDFLAG) + +%.o:%.c + $(CC) -o $@ -c $< $(CFLAG) + +.PHONY:clean + +clean: + rm -rf $(EXEC) \ No newline at end of file diff --git a/travail_individuel/Belkhiri/snakes/run b/travail_individuel/Belkhiri/snakes/run new file mode 100755 index 0000000000000000000000000000000000000000..6338c0e03adad271a3f22d17e9e5d4567fb494bd Binary files /dev/null and b/travail_individuel/Belkhiri/snakes/run differ diff --git a/travail_individuel/Belkhiri/snakes/snakes.c b/travail_individuel/Belkhiri/snakes/snakes.c new file mode 100644 index 0000000000000000000000000000000000000000..40cbd7925ddfedbc58cfd95c0b320e495666e078 --- /dev/null +++ b/travail_individuel/Belkhiri/snakes/snakes.c @@ -0,0 +1,233 @@ +#include <SDL2/SDL.h> +#include <math.h> +#include <stdio.h> +#include <string.h> + +#define NB_BLOCS 4 +#define NB_SNAKES 10 + +typedef struct bloc { + int p1[2]; + int p2[2]; + int p3[2]; + int p4[2]; +} bloc_t; + +typedef struct snake { + bloc_t * blocs[NB_BLOCS]; +} snake_t; + + +int running = 1; + +void end_sdl(char ok, + char const* msg, + SDL_Window* window, + SDL_Renderer* renderer) { + char msg_formated[255]; + int l; + + if (!ok) { + strncpy(msg_formated, msg, 250); + l = strlen(msg_formated); + strcpy(msg_formated + l, " : %s\n"); + + SDL_Log(msg_formated, SDL_GetError()); + } + + if (renderer != NULL) { + SDL_DestroyRenderer(renderer); + renderer = NULL; + } + if (window != NULL) { + SDL_DestroyWindow(window); + window= NULL; + } + + SDL_Quit(); + + if (!ok) { + exit(EXIT_FAILURE); + } +} + +void draw_snake(SDL_Renderer* renderer, snake_t * Snake_to_draw) { + for (int i = 0; i < NB_BLOCS; i++) { + SDL_SetRenderDrawColor(renderer, rand() % 255, rand() % 255, rand() % 255, 255); + SDL_RenderDrawLine(renderer, Snake_to_draw->blocs[i]->p1[0], Snake_to_draw->blocs[i]->p1[1], Snake_to_draw->blocs[i]->p2[0], Snake_to_draw->blocs[i]->p2[1]); + SDL_RenderDrawLine(renderer, Snake_to_draw->blocs[i]->p2[0], Snake_to_draw->blocs[i]->p2[1], Snake_to_draw->blocs[i]->p3[0], Snake_to_draw->blocs[i]->p3[1]); + SDL_RenderDrawLine(renderer, Snake_to_draw->blocs[i]->p3[0], Snake_to_draw->blocs[i]->p3[1], Snake_to_draw->blocs[i]->p4[0], Snake_to_draw->blocs[i]->p4[1]); + SDL_RenderDrawLine(renderer, Snake_to_draw->blocs[i]->p4[0], Snake_to_draw->blocs[i]->p4[1], Snake_to_draw->blocs[i]->p1[0], Snake_to_draw->blocs[i]->p1[1]); + SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); + } +} + +snake_t * init_snake(int x, int y, int h, int w) { + snake_t * snake = malloc(sizeof(snake_t)); + for (int i = 0; i < NB_BLOCS; i++) { + snake->blocs[i] = malloc(sizeof(bloc_t)); + if (i == 0){ + snake->blocs[i]->p1[0] = x; + snake->blocs[i]->p1[1] = y; + snake->blocs[i]->p2[0] = x; + snake->blocs[i]->p2[1] = y+h; + snake->blocs[i]->p3[0] = x+w; + snake->blocs[i]->p3[1] = y+h; + snake->blocs[i]->p4[0] = x+w; + snake->blocs[i]->p4[1] = y; + } + else { + snake->blocs[i]->p1[0] = snake->blocs[i-1]->p2[0]; + snake->blocs[i]->p1[1] = snake->blocs[i-1]->p2[1]; + snake->blocs[i]->p2[0] = snake->blocs[i]->p1[0]; + snake->blocs[i]->p2[1] = snake->blocs[i]->p1[1] + h/(i+2); + snake->blocs[i]->p4[0] = snake->blocs[i-1]->p3[0]; + snake->blocs[i]->p4[1] = snake->blocs[i-1]->p3[1]; + snake->blocs[i]->p3[0] = snake->blocs[i]->p4[0]; + snake->blocs[i]->p3[1] = snake->blocs[i]->p4[1] + h/(i+2); + } + } + return snake; +} + +void rotate_bloc(float angle, bloc_t * bloc){ + float x1 = bloc->p1[0]; + float y1 = bloc->p1[1]; + float x2 = bloc->p2[0]; + float y2 = bloc->p2[1]; + float x3 = bloc->p3[0]; + float y3 = bloc->p3[1]; + float x4 = bloc->p4[0]; + float y4 = bloc->p4[1]; + // middle is center of rotation + float middle_x = (x1 + x4)/2; + float middle_y = (y1 + y4)/2; + + float x1_new = x1 - middle_x; + float y1_new = y1 - middle_y; + float x2_new = x2 - middle_x; + float y2_new = y2 - middle_y; + float x3_new = x3 - middle_x; + float y3_new = y3 - middle_y; + float x4_new = x4 - middle_x; + float y4_new = y4 - middle_y; + // rotate + x1_new = x1_new * cos(angle) - y1_new * sin(angle); + y1_new = x1_new * sin(angle) + y1_new * cos(angle); + x2_new = x2_new * cos(angle) - y2_new * sin(angle); + y2_new = x2_new * sin(angle) + y2_new * cos(angle); + x3_new = x3_new * cos(angle) - y3_new * sin(angle); + y3_new = x3_new * sin(angle) + y3_new * cos(angle); + x4_new = x4_new * cos(angle) - y4_new * sin(angle); + y4_new = x4_new * sin(angle) + y4_new * cos(angle); + // move back + x1_new = x1_new + middle_x; + y1_new = y1_new + middle_y; + x2_new = x2_new + middle_x; + y2_new = y2_new + middle_y; + x3_new = x3_new + middle_x; + y3_new = y3_new + middle_y; + x4_new = x4_new + middle_x; + y4_new = y4_new + middle_y; + // assign new values + bloc->p1[0] = x1_new; + bloc->p1[1] = y1_new; + bloc->p2[0] = x2_new; + bloc->p2[1] = y2_new; + bloc->p3[0] = x3_new; + bloc->p3[1] = y3_new; + bloc->p4[0] = x4_new; + bloc->p4[1] = y4_new; +} + +float random_angle_radian() { + return (float)rand() / (float)RAND_MAX * 2 * M_PI; +} + +void move_bloc(int x, int y, bloc_t * bloc){ + bloc->p1[0] += x; + bloc->p1[1] += y; + bloc->p2[0] += x; + bloc->p2[1] += y; + bloc->p3[0] += x; + bloc->p3[1] += y; + bloc->p4[0] += x; + bloc->p4[1] += y; +} + +void move_snake(int x, int y, snake_t * snake){ + for (int i = NB_BLOCS-1; i >= 0; i--) { + move_bloc(x, y, snake->blocs[i]); + } +} + +void rotate_snake(float angle, snake_t * snake) { + for (int i = 0; i < NB_BLOCS; i++) { + if (i == 0){ + rotate_bloc(angle, snake->blocs[i]); + } + else { + rotate_bloc(angle, snake->blocs[i]); + snake->blocs[i]->p1[0] = snake->blocs[i-1]->p2[0]; + snake->blocs[i]->p1[1] = snake->blocs[i-1]->p2[1]; + snake->blocs[i]->p4[0] = snake->blocs[i-1]->p3[0]; + snake->blocs[i]->p4[1] = snake->blocs[i-1]->p3[1]; + } + } +} + +int main(int argc, char** argv) { + (void)argc; + (void)argv; + + SDL_Window* window = NULL; + SDL_Renderer* renderer = NULL; + + SDL_DisplayMode screen; + + /*********************************************************************************************************************/ + /* Initialisation de la SDL + gestion de l'échec possible */ + if (SDL_Init(SDL_INIT_VIDEO) != 0) end_sdl(0, "ERROR SDL INIT", window, renderer); + + SDL_GetCurrentDisplayMode(0, &screen); + printf("Résolution écran\n\tw : %d\n\th : %d\n", + screen.w, screen.h); + + /* Création de la fenêtre */ + window = SDL_CreateWindow("Premier dessin", + SDL_WINDOWPOS_CENTERED, + SDL_WINDOWPOS_CENTERED, screen.w, + screen.h, + SDL_WINDOW_OPENGL); + if (window == NULL) end_sdl(0, "ERROR WINDOW CREATION", window, renderer); + + /* Création du renderer */ + renderer = SDL_CreateRenderer(window, -1, + SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC); + if (renderer == NULL) end_sdl(0, "ERROR RENDERER CREATION", window, renderer); + + snake_t * snakeList[NB_SNAKES]; + for (int i = 0; i < NB_SNAKES; i++) { + // random int between 0 and WIDTH + + snakeList[i] = init_snake(rand()%screen.w, rand()%screen.h, rand()%200, rand()%50); + } + + for (int i=0; i< 50; i++){ + for (int j=0; j<NB_SNAKES; j++){ + float angle = 0.2 * pow(-1, 1 + rand()%2); + rotate_snake(angle, snakeList[j]); + move_snake(rand()%10, rand()%10, snakeList[j]); + draw_snake(renderer, snakeList[j]); + } + SDL_RenderPresent(renderer); + SDL_Delay(100); + SDL_RenderClear(renderer); + } + + + + /* on referme proprement la SDL */ + end_sdl(1, "Normal ending", window, renderer); + return EXIT_SUCCESS; +} \ No newline at end of file diff --git a/travail_individuel/Belkhiri/x_fenetre/Makefile b/travail_individuel/Belkhiri/x_fenetre/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..e76de77896acfdf5d8d8e97b8a1c9504c2364375 --- /dev/null +++ b/travail_individuel/Belkhiri/x_fenetre/Makefile @@ -0,0 +1,21 @@ +CC=gcc + +LDFLAG=$(shell sdl2-config --cflags --libs) -lm -lSDL2_ttf -D_REENTRANT -lSDL2_image -pthread +CFLAG=-Wall $(shell sdl2-config --cflags --libs) + +EXEC=run +SRC=$(wildcard *.c) +OBJ=$(SRC:.c=.o) + +all:$(EXEC) + +$(EXEC):$(OBJ) + $(CC) -o $@ $^ $(LDFLAG) + +%.o:%.c + $(CC) -o $@ -c $< $(CFLAG) + +.PHONY:clean + +clean: + rm -rf $(EXEC) \ No newline at end of file diff --git a/travail_individuel/Belkhiri/x_fenetre/X.c b/travail_individuel/Belkhiri/x_fenetre/X.c new file mode 100644 index 0000000000000000000000000000000000000000..2d5a68fbf92fd56439bdb235ff3782c02e99f836 --- /dev/null +++ b/travail_individuel/Belkhiri/x_fenetre/X.c @@ -0,0 +1,100 @@ +#include <SDL2/SDL.h> +#include <stdio.h> + + +int main(int argc, char **argv) { + (void)argc; + (void)argv; + + int screen_width = 1079; + int screen_height = 1920; + + SDL_Window * windows[20]; + + int bounce_count = 0; + int amplitude_bounce = 200; + int left_most_position = 0; + int top_most_position = 0; + + if (SDL_Init(SDL_INIT_VIDEO) != 0) { + SDL_Log("Error : SDL initialisation - %s\n", + SDL_GetError()); + exit(EXIT_FAILURE); + } + int pas_y = (screen_height)/20; + int pas_x = (screen_width)/20; + int last_drawy = 0; + + for (int i = 0; i < 10; i++) { + int draw_x = top_most_position + i * pas_x; + int draw_y = left_most_position + i * pas_y; + last_drawy = draw_y; + windows[i] = SDL_CreateWindow("Window", + draw_y , draw_x, + 400, 300, + SDL_WINDOW_SHOWN); + if (windows[i] == NULL) { + SDL_Log("Error : SDL window creation - %s\n", + SDL_GetError()); + exit(EXIT_FAILURE); + } + SDL_Delay(50); + } + + for (int i = 10; i < 20; i++) { + int draw_x = top_most_position + (i-10) * pas_x; + int draw_y = last_drawy - (i-10) * pas_y; + windows[i] = SDL_CreateWindow("Window", + draw_y , draw_x, + 400, 300, + SDL_WINDOW_SHOWN); + if (windows[i] == NULL) { + SDL_Log("Error : SDL window creation - %s\n", + SDL_GetError()); + exit(EXIT_FAILURE); + } + SDL_Delay(50); + } + + SDL_Delay(100); + + while (bounce_count < 50) { + + + for (int i = 0; i < 10; i++) { + int draw_x = top_most_position + i * pas_x; + int draw_y = left_most_position + i * pas_y; + last_drawy = draw_y; + SDL_SetWindowPosition(windows[i], + draw_y , draw_x); + + //SDL_Delay(50); + } + + for (int i = 10; i < 20; i++) { + int draw_x = top_most_position + (i-10) * pas_x; + int draw_y = last_drawy - (i-10) * pas_y; + SDL_SetWindowPosition(windows[i], + draw_y , draw_x); + //SDL_Delay(50); + } + + SDL_Delay(100); + + + bounce_count+=1; + int signe = (bounce_count % 2 == 0) ? (1) : (-1); + left_most_position = left_most_position + amplitude_bounce; + amplitude_bounce = 200 * sin(bounce_count); + } + for (int i = 0; i < 20; i++) { + SDL_DestroyWindow(windows[i]); + } + + + SDL_Delay(2000); + + SDL_Quit(); + + return 0; +} \ No newline at end of file diff --git a/travail_individuel/Belkhiri/x_fenetre/run b/travail_individuel/Belkhiri/x_fenetre/run new file mode 100755 index 0000000000000000000000000000000000000000..64084e4825d6614c016394579ef63b7ad36a1453 Binary files /dev/null and b/travail_individuel/Belkhiri/x_fenetre/run differ diff --git a/travail_individuel/Meyer/pave_de_serpents/main b/travail_individuel/Meyer/pave_de_serpents/main new file mode 100755 index 0000000000000000000000000000000000000000..0130edc9e30a444de3016821db2bb91eb1982ae1 Binary files /dev/null and b/travail_individuel/Meyer/pave_de_serpents/main differ diff --git a/travail_individuel/Meyer/pave_de_serpents/main.c b/travail_individuel/Meyer/pave_de_serpents/main.c new file mode 100644 index 0000000000000000000000000000000000000000..cbf26667f7b73b16bae5130e0243e23ecf9b2875 --- /dev/null +++ b/travail_individuel/Meyer/pave_de_serpents/main.c @@ -0,0 +1,141 @@ +#include <SDL2/SDL.h> +#include <stdio.h> +#include <stdlib.h> + +int main(int argc, char **argv) +{ + (void)argc; + (void)argv; + + int vainqueur = 0; + + SDL_Window + *window = NULL; + + int window_width = 1000; + int window_height = 700; + int window_x; + int window_y; + + SDL_InitSubSystem(SDL_INIT_VIDEO); + SDL_DisplayMode mode; + int display_width; + int display_height; + + SDL_Renderer *renderer; + SDL_Rect rect; + + int pale_1_x; + int pale_1_y; + + if (SDL_GetDesktopDisplayMode(0, &mode) != 0) + { + SDL_Log("SDL_GetDesktopDisplayMode failed: %s", SDL_GetError()); + return 1; + } + display_width = mode.w; + display_height = mode.h; + + /* Initialisation de la SDL + gestion de l'échec possible */ + if (SDL_Init(SDL_INIT_VIDEO) != 0) + { + SDL_Log("Error : SDL initialisation - %s\n", + SDL_GetError()); // l'initialisation de la SDL a échoué + exit(EXIT_FAILURE); + } + + /* Création de la fenêtre */ + window_x = (display_width - window_width) / 2; + window_y = (display_height - window_height) / 2; + window = SDL_CreateWindow( + "Moulin à serpents", + window_x, window_y, // centrage de la fenêtre + window_width, window_height, // largeur, hauteur + SDL_WINDOW_RESIZABLE); // redimensionnable + + if (window == NULL) + { + SDL_Log("Error : SDL window 1 creation - %s\n", + SDL_GetError()); // échec de la création de la fenêtre + SDL_Quit(); // On referme la SDL + exit(EXIT_FAILURE); + } + + renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED); /* SDL_RENDERER_SOFTWARE */ + if (renderer == 0) + { + fprintf(stderr, "Erreur d'initialisation de la SDL : %s\n", SDL_GetError()); + + SDL_Quit(); // On referme la SDL + exit(EXIT_FAILURE); + } + + // dessin + /* couleur de fond */ + SDL_SetRenderDrawColor(renderer, 157, 224, 144, 255); + SDL_RenderClear(renderer); + + //sol + SDL_SetRenderDrawColor(renderer, 49, 150, 29, 255); + rect.w = window_width; + rect.h = window_height/3; + rect.x = 0; + rect.y = window_height - window_height/3; + SDL_RenderFillRect(renderer, &rect); + + /* bloc du moulin */ + SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255); + rect.w = 150; + rect.h = 250; + rect.x = (window_width - rect.w)/2; + rect.y = window_height - rect.h - 150; + SDL_RenderFillRect(renderer, &rect); + + /*triangle moulin*/ + SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255); + rect.w = 150; + rect.h = 50; + rect.x = (window_width - rect.w)/2; + rect.y = window_height - rect.h - 400; + SDL_RenderFillRect(renderer, &rect); + + //pales du moulin + //pale 1 du moulin + pale_1_x = 50; + pale_1_y = 50; + SDL_SetRenderDrawColor(renderer, 163, 82, 2, 255); + SDL_RenderDrawLine(renderer, + (window_width - rect.w)/2, + window_height - rect.h - 400, + pale_1_x, + pale_1_y); + + + + /* afficher à l'ecran */ + SDL_RenderPresent(renderer); + + + + // départ de la course + /*while (vainqueur == 0) + { + + if (cercle.x > display_width) + { + vainqueur = 1; + } + }*/ + + // ecrire victoire + + + SDL_Delay(2000); + + // fermer fenetre + SDL_DestroyWindow(window); // la fenêtre + + SDL_Quit(); // la SDL + + return 0; +} \ No newline at end of file diff --git a/travail_individuel/Meyer/pave_de_serpents/makefile b/travail_individuel/Meyer/pave_de_serpents/makefile new file mode 100644 index 0000000000000000000000000000000000000000..9e978d1309fe9b051df7c0c3bdd1e125a4aa5612 --- /dev/null +++ b/travail_individuel/Meyer/pave_de_serpents/makefile @@ -0,0 +1,11 @@ +CC=gcc + +main:main.o + $(CC) -o main main.o -lm -lSDL2 + @echo "=> Lancer le programme avec ./main" + +main.o:main.c + $(CC) -c main.c -g -Wall -Wextra + +clean: + rm -rf main main.o diff --git a/travail_individuel/Meyer/x_fenetre/main b/travail_individuel/Meyer/x_fenetre/main index 7bf1acd0815506a43370b36047ca7915b79119b2..aa877aac15abe13dac12a5ae482f867d4e59a463 100755 Binary files a/travail_individuel/Meyer/x_fenetre/main and b/travail_individuel/Meyer/x_fenetre/main differ diff --git a/travail_individuel/Meyer/x_fenetre/main.c b/travail_individuel/Meyer/x_fenetre/main.c index 219430376007c21bbd2fac2bd3acaf60343cb886..ce85e6a5c0db57af11c9c9d06c08e53b34f65bb0 100644 --- a/travail_individuel/Meyer/x_fenetre/main.c +++ b/travail_individuel/Meyer/x_fenetre/main.c @@ -1,5 +1,8 @@ #include <SDL2/SDL.h> #include <stdio.h> +#include <stdlib.h> +#include <time.h> +#include <math.h> int main(int argc, char **argv) { @@ -14,6 +17,8 @@ int main(int argc, char **argv) int window_x; int window_y; + int number_of_stars = 10; + SDL_InitSubSystem(SDL_INIT_VIDEO); SDL_DisplayMode mode; int display_width; @@ -36,13 +41,13 @@ int main(int argc, char **argv) } /* Création de la fenêtre */ - window_x = (display_width-window_width)/2; + window_x = (display_width - window_width) / 2; window_y = display_height; window = SDL_CreateWindow( - "Rocket", - window_x, window_y, // centrage de la fenêtre - window_width, window_height, // largeur = 400, hauteur = 300 - SDL_WINDOW_RESIZABLE); // redimensionnable + "Rocket : 3", + window_x, window_y, // centrage de la fenêtre + window_width, window_height, // largeur = 400, hauteur = 300 + SDL_WINDOW_RESIZABLE); // redimensionnable if (window == NULL) { @@ -52,17 +57,71 @@ int main(int argc, char **argv) exit(EXIT_FAILURE); } + // decompte decollage + SDL_Delay(1000); + SDL_SetWindowTitle(window, "Rocket : 2"); + SDL_Delay(1000); + SDL_SetWindowTitle(window, "Rocket : 1"); + SDL_Delay(1000); + SDL_SetWindowTitle(window, "Rocket : FEU!"); + SDL_Delay(1000); + SDL_SetWindowTitle(window, "Rocket"); - - while(window_y > 0){ + while (window_y > 0) + { + window_width = window_width - 15; + window_x = (display_width - window_width) / 2; window_y = window_y - 100; + SDL_SetWindowSize(window, window_width, window_height); SDL_SetWindowPosition(window, window_x, window_y); - SDL_Delay(1000); // Pause exprimée en ms + SDL_Delay(200); // Pause exprimée en ms } - /* et on referme tout ce qu'on a ouvert en ordre inverse de la création */ + // explosion de la rocket SDL_DestroyWindow(window); // la fenêtre + // aleatoire + srand(time(0)); + // creation de [number_of_stars] etoiles dans des directions aleatoires + SDL_Window *window_stars[20]; + int tab_window_x[20]; + int tab_window_y[20]; + int tab_direction[20]; + for (int i = 1; i <= number_of_stars; i++) + { + int width_r = 50 + rand() % 100; + int height_r = 50 + rand() % 50; + tab_window_x[i] = (display_width - width_r) / 2; + tab_window_y[i] = 0; + tab_direction[i] = pow(-1, 1+(rand()%2)); // donne -1 ou 1 + + window_stars[i] = SDL_CreateWindow( + "Étoile", + tab_window_x[i], tab_window_y[i], + width_r, height_r, + SDL_WINDOW_RESIZABLE); + + SDL_Delay(10); // Pause exprimée en ms + } + + // déplacement des etoiles + for (int temps = 0; temps <= 5; temps++) + { + for (int i = 1; i <= number_of_stars; i++) + { + tab_window_y[i] = tab_window_y[i] + 20 + rand()%70; + tab_window_x[i] = tab_window_x[i] + tab_direction[i]*(rand()%200); + SDL_SetWindowPosition(window_stars[i], tab_window_x[i], tab_window_y[i]); + } + SDL_Delay(400); + } + + // destruction des etoiles + for (int i = 1; i <= number_of_stars; i++) + { + SDL_DestroyWindow(window_stars[i]); + } + SDL_Quit(); // la SDL return 0;