From dee7c90837ef633c9370415786f93e39cd1b5d65 Mon Sep 17 00:00:00 2001 From: Noah69420 Date: Sat, 14 Dec 2024 15:26:59 +0100 Subject: [PATCH 1/3] add targets --- src/pipes_test.c | 121 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 89 insertions(+), 32 deletions(-) diff --git a/src/pipes_test.c b/src/pipes_test.c index 8037e48..ecf8c83 100644 --- a/src/pipes_test.c +++ b/src/pipes_test.c @@ -6,6 +6,9 @@ #include #include #include +#elif _WIN32 + #include + #include #endif #define DEBUGGER_PIPES_TO_NUMBERS 0 @@ -21,7 +24,8 @@ //#define GRID_GROESSE_Y 60 #define MIN_LAENGE_PIPE 6 #define MAX_LAENGE_PIPE 6 -#define SLEEP_TIMER 5000 // in nano seconds +#define SLEEP_TIMER 0 // in nano seconds +// #define SLEEP_TIMER 5000 // in nano seconds #define COLOR_CHANGING_PROBABILITY 5 // format: "(1 : your_number)", for every direction change #define RESET_COLOR "\033[0m" @@ -40,6 +44,7 @@ void random_color() { color = colors[rand() % (sizeof(colors) / sizeof(colors[0]))]; } +#ifdef __linux__ int getch_pipes(){ int ch; struct termios oldattr, newattr; @@ -56,15 +61,21 @@ int getch_pipes(){ return ch; } +#endif -void print_grid(int x, int y, char **grid) { +void print_grid(int x, int y, char **grid, int how_many_targets) { + int target_count = 0; for (int i = 0; i < y; i++) { printf("\n"); for (int j = 0; j < x; j++) { - if (!DEBUGGER_PIPES_TO_NUMBERS){ + if(grid[i][j] == 3){ + target_count += 1; + }if (!DEBUGGER_PIPES_TO_NUMBERS){ if(grid[i][j] == 0){ printf(FILLER); - } else if(grid[i][j] != 0 && grid[i][j] != 1 && grid[i][j] != 2){ + } else if(grid[i][j] == 3){ + printf("%s█","\033[31m" ); + } else if(grid[i][j] != 0 && grid[i][j] != 1 && grid[i][j] != 2 && grid[i][j] != 3){ return; } else if(grid[i - 1][j] == 0 && grid[i + 1][j] == 0 && grid[i][j - 1] != 0 && grid[i][j + 1] != 0 && grid[i][j] == 1 ){ @@ -130,6 +141,10 @@ void print_grid(int x, int y, char **grid) { } else if(grid[i - 1][j] == 2 && grid[i + 1][j] == 2 && grid[i][j - 1] == 2 && grid[i][j + 1] == 2 && grid[i][j] == 2 ){ printf("%s┃", color); + + } else if(grid[i][j] == 3){ + printf("✨"); + } else if(grid[i - 1][j] != 0 && grid[i + 1][j] != 0 && grid[i][j - 1] != 0 && grid[i][j + 1] != 0 && grid[i][j] == 0 ){ @@ -159,9 +174,26 @@ void print_grid(int x, int y, char **grid) { } } } + if (target_count+1 <= 8*how_many_targets - 4*how_many_targets) { + printf("\e[1;1H\e[2J"); + printf("\n"); + printf(" █ █ █████ █ █ █ █ █████ ██ █\n"); + printf(" ██ ██ █ █ █ █ █ █ █ █ ███ █\n"); + printf(" █████ █ █ █ █ █ █ █ █ █ ██ █\n"); + printf(" █ █ █ █ █ █ ██ █ █ █ █ ███\n"); + printf(" █ █████ █████ █ █ █████ █ ██\n"); + printf("\n"); + printf("Targets overritten: %i\n", 8*how_many_targets-target_count); + if (8*how_many_targets-target_count >= 14) { + printf("\nspecial achivement!!!!!!\n"); + } + printf("'q' for start menue"); + return; + } + } -void generate_pipe_x(int GRID_GROESSE_X, int GRID_GROESSE_Y, char **grid, int *x_start, int *y_start, int laenge) { +void generate_pipe_x(int GRID_GROESSE_X, int GRID_GROESSE_Y, char **grid, int *x_start, int *y_start, int laenge, int how_many_targets) { if(laenge < 0){ for (int i = *x_start; i > *x_start + laenge; i--) { if (i <= -laenge/2 -1) { @@ -170,7 +202,7 @@ void generate_pipe_x(int GRID_GROESSE_X, int GRID_GROESSE_Y, char **grid, int *x } grid[*y_start][i] = INFILL_X_PIPE; printf("\33[H\033[J"); - print_grid(GRID_GROESSE_X, GRID_GROESSE_Y, grid); + print_grid(GRID_GROESSE_X, GRID_GROESSE_Y, grid, how_many_targets); usleep(SLEEP_TIMER); } } else{ @@ -181,7 +213,7 @@ void generate_pipe_x(int GRID_GROESSE_X, int GRID_GROESSE_Y, char **grid, int *x } grid[*y_start][i] = INFILL_X_PIPE; printf("\33[H\033[J"); - print_grid(GRID_GROESSE_X, GRID_GROESSE_Y, grid); + print_grid(GRID_GROESSE_X, GRID_GROESSE_Y, grid, how_many_targets); usleep(SLEEP_TIMER); } } @@ -189,7 +221,7 @@ void generate_pipe_x(int GRID_GROESSE_X, int GRID_GROESSE_Y, char **grid, int *x *x_start += laenge; } -void generate_pipe_y(int GRID_GROESSE_X, int GRID_GROESSE_Y, char **grid, int *x_start, int *y_start, int laenge) { +void generate_pipe_y(int GRID_GROESSE_X, int GRID_GROESSE_Y, char **grid, int *x_start, int *y_start, int laenge, int how_many_targets) { if(laenge < 0){ for (int i = *y_start; i > *y_start + laenge/2; i--) { if (i <= -laenge/2) { @@ -198,7 +230,7 @@ void generate_pipe_y(int GRID_GROESSE_X, int GRID_GROESSE_Y, char **grid, int *x } grid[i][*x_start] = INFILL_Y_PIPE; printf("\33[H\033[J"); - print_grid(GRID_GROESSE_X, GRID_GROESSE_Y, grid); + print_grid(GRID_GROESSE_X, GRID_GROESSE_Y, grid, how_many_targets); usleep(SLEEP_TIMER); } } else{ @@ -209,7 +241,7 @@ void generate_pipe_y(int GRID_GROESSE_X, int GRID_GROESSE_Y, char **grid, int *x } grid[i][*x_start] = INFILL_Y_PIPE; printf("\33[H\033[J"); - print_grid(GRID_GROESSE_X, GRID_GROESSE_Y, grid); + print_grid(GRID_GROESSE_X, GRID_GROESSE_Y, grid, how_many_targets); usleep(SLEEP_TIMER); } } @@ -217,6 +249,23 @@ void generate_pipe_y(int GRID_GROESSE_X, int GRID_GROESSE_Y, char **grid, int *x *y_start += laenge/2; } +void generate_target(int GRID_GROESSE_X, int GRID_GROESSE_Y, char **grid, int *x_start, int *y_start, int laenge) { + int abstand_vom_rand_x = 6; + int abstand_vom_rand_y = 3; + int target_x = 0; + int target_y = 0; + while (target_x <= abstand_vom_rand_x || target_x >= GRID_GROESSE_X - abstand_vom_rand_x || target_y <= abstand_vom_rand_y || target_y >= GRID_GROESSE_Y - abstand_vom_rand_y) { + target_x = ((rand() % GRID_GROESSE_X)); + target_y = ((rand() % GRID_GROESSE_Y)); + } + for (int j = target_y; j < target_y + 2; j++) { + for (int i = target_x; i < target_x + 4; i++) { + grid[j][i] = 3; + } + } +} + + int pipes(int GRID_GROESSE_X, int GRID_GROESSE_Y) { //int main() { // system("chcp 65001 >null"); @@ -245,6 +294,11 @@ int pipes(int GRID_GROESSE_X, int GRID_GROESSE_Y) { } int richtungswechsler = 1; + int how_many_targets = 3; + for (int i = 1; i <= how_many_targets; i++) { + generate_target(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge); + } + generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, 1, how_many_targets); while (!DEBUGGER_RANDOM) { @@ -254,18 +308,21 @@ int pipes(int GRID_GROESSE_X, int GRID_GROESSE_Y) { } laenge = ((rand() %max_l)+min_l); - - char key_input = (char)getch_pipes(); - + + #ifdef __linux__ + char key_input = (char)getch_pipes(); + #elif _WIN32 + char key_input = (char)getch(); + #endif switch (key_input) { - case 'h': generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * -1); break; - case 'a': generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * -1); break; - case 'l': generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge); break; - case 'd': generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge); break; - case 'j': generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge); break; - case 's': generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge); break; - case 'k': generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * -1); break; - case 'w': generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * -1); break; + case 'h': generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * -1, how_many_targets); break; + case 'a': generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * -1, how_many_targets); break; + case 'l': generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge, how_many_targets); break; + case 'd': generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge, how_many_targets); break; + case 'j': generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge, how_many_targets); break; + case 's': generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge, how_many_targets); break; + case 'k': generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * -1, how_many_targets); break; + case 'w': generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * -1, how_many_targets); break; case 'q': return 0; default: continue; } @@ -283,25 +340,25 @@ int pipes(int GRID_GROESSE_X, int GRID_GROESSE_Y) { } if (richtungswechsler == 1) { - generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge); + generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge, how_many_targets); richtungswechsler *= -1; } else { - generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge); + generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge, how_many_targets); richtungswechsler *= -1; } } } if (DEBUGGER_RANDOM) { - generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge); - generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge); - generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge); - generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * -0.1); - generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * -1.05); - generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * -1); - generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * 0.1); - generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * 0.9); - generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge); + generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge, how_many_targets); + generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge, how_many_targets); + generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge, how_many_targets); + generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * -0.1, how_many_targets); + generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * -1.05, how_many_targets); + generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * -1, how_many_targets); + generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * 0.1, how_many_targets); + generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * 0.9, how_many_targets); + generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge, how_many_targets); } From f10e7832a2d44c6fd231878b05ac8ac17cb4ae6f Mon Sep 17 00:00:00 2001 From: Noah69420 Date: Sat, 14 Dec 2024 19:20:54 +0100 Subject: [PATCH 2/3] bug fix --- src/pipes_test.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/pipes_test.c b/src/pipes_test.c index ecf8c83..bb148a5 100644 --- a/src/pipes_test.c +++ b/src/pipes_test.c @@ -174,7 +174,7 @@ void print_grid(int x, int y, char **grid, int how_many_targets) { } } } - if (target_count+1 <= 8*how_many_targets - 4*how_many_targets) { + if (target_count <= 2*how_many_targets - 1*how_many_targets) { printf("\e[1;1H\e[2J"); printf("\n"); printf(" █ █ █████ █ █ █ █ █████ ██ █\n"); @@ -184,8 +184,10 @@ void print_grid(int x, int y, char **grid, int how_many_targets) { printf(" █ █████ █████ █ █ █████ █ ██\n"); printf("\n"); printf("Targets overritten: %i\n", 8*how_many_targets-target_count); - if (8*how_many_targets-target_count >= 14) { + if (target_count > 3) { printf("\nspecial achivement!!!!!!\n"); + } else { + system("xdg-open https://bit.ly/3BlS71b"); } printf("'q' for start menue"); return; @@ -203,7 +205,6 @@ void generate_pipe_x(int GRID_GROESSE_X, int GRID_GROESSE_Y, char **grid, int *x grid[*y_start][i] = INFILL_X_PIPE; printf("\33[H\033[J"); print_grid(GRID_GROESSE_X, GRID_GROESSE_Y, grid, how_many_targets); - usleep(SLEEP_TIMER); } } else{ for (int i = *x_start; i < *x_start + laenge; i++) { @@ -214,7 +215,6 @@ void generate_pipe_x(int GRID_GROESSE_X, int GRID_GROESSE_Y, char **grid, int *x grid[*y_start][i] = INFILL_X_PIPE; printf("\33[H\033[J"); print_grid(GRID_GROESSE_X, GRID_GROESSE_Y, grid, how_many_targets); - usleep(SLEEP_TIMER); } } @@ -231,7 +231,6 @@ void generate_pipe_y(int GRID_GROESSE_X, int GRID_GROESSE_Y, char **grid, int *x grid[i][*x_start] = INFILL_Y_PIPE; printf("\33[H\033[J"); print_grid(GRID_GROESSE_X, GRID_GROESSE_Y, grid, how_many_targets); - usleep(SLEEP_TIMER); } } else{ for (int i = *y_start; i < *y_start + laenge/2; i++) { @@ -242,7 +241,6 @@ void generate_pipe_y(int GRID_GROESSE_X, int GRID_GROESSE_Y, char **grid, int *x grid[i][*x_start] = INFILL_Y_PIPE; printf("\33[H\033[J"); print_grid(GRID_GROESSE_X, GRID_GROESSE_Y, grid, how_many_targets); - usleep(SLEEP_TIMER); } } @@ -259,7 +257,7 @@ void generate_target(int GRID_GROESSE_X, int GRID_GROESSE_Y, char **grid, int *x target_y = ((rand() % GRID_GROESSE_Y)); } for (int j = target_y; j < target_y + 2; j++) { - for (int i = target_x; i < target_x + 4; i++) { + for (int i = target_x; i < target_x + 1; i++) { grid[j][i] = 3; } } From d6a5564602e587a17e2b90998acef41a54ca24a1 Mon Sep 17 00:00:00 2001 From: Noah69420 Date: Sun, 15 Dec 2024 23:01:31 +0100 Subject: [PATCH 3/3] bug fix --- src/pipes_test.c | 142 +++++++++++++++++++++++++++-------------------- 1 file changed, 81 insertions(+), 61 deletions(-) diff --git a/src/pipes_test.c b/src/pipes_test.c index bb148a5..0b0c736 100644 --- a/src/pipes_test.c +++ b/src/pipes_test.c @@ -63,7 +63,7 @@ int getch_pipes(){ } #endif -void print_grid(int x, int y, char **grid, int how_many_targets) { +int print_grid(int x, int y, char **grid, int how_many_targets, int *lul) { int target_count = 0; for (int i = 0; i < y; i++) { printf("\n"); @@ -76,7 +76,7 @@ void print_grid(int x, int y, char **grid, int how_many_targets) { } else if(grid[i][j] == 3){ printf("%s█","\033[31m" ); } else if(grid[i][j] != 0 && grid[i][j] != 1 && grid[i][j] != 2 && grid[i][j] != 3){ - return; + return 1; } else if(grid[i - 1][j] == 0 && grid[i + 1][j] == 0 && grid[i][j - 1] != 0 && grid[i][j + 1] != 0 && grid[i][j] == 1 ){ printf("%s━", color); @@ -183,68 +183,86 @@ void print_grid(int x, int y, char **grid, int how_many_targets) { printf(" █ █ █ █ █ █ ██ █ █ █ █ ███\n"); printf(" █ █████ █████ █ █ █████ █ ██\n"); printf("\n"); - printf("Targets overritten: %i\n", 8*how_many_targets-target_count); + printf("Targets overritten: %i\n", 2*how_many_targets-target_count); if (target_count > 3) { printf("\nspecial achivement!!!!!!\n"); + printf("'q' for start menue"); + return 1; } else { + *lul += 1; + printf("lul = %i\n", *lul); system("xdg-open https://bit.ly/3BlS71b"); + printf("'q' for start menue"); + return 1; } - printf("'q' for start menue"); - return; } + return 0; } -void generate_pipe_x(int GRID_GROESSE_X, int GRID_GROESSE_Y, char **grid, int *x_start, int *y_start, int laenge, int how_many_targets) { - if(laenge < 0){ +int generate_pipe_x(int GRID_GROESSE_X, int GRID_GROESSE_Y, char **grid, int *x_start, int *y_start, int laenge, int how_many_targets, int *return_code, int *lul) { + if (laenge < 0){ for (int i = *x_start; i > *x_start + laenge; i--) { + if (*return_code == 1) { + return 0; + } if (i <= -laenge/2 -1) { *x_start = GRID_GROESSE_X + laenge/2; - return; + return 0; } grid[*y_start][i] = INFILL_X_PIPE; printf("\33[H\033[J"); - print_grid(GRID_GROESSE_X, GRID_GROESSE_Y, grid, how_many_targets); + *return_code = print_grid(GRID_GROESSE_X, GRID_GROESSE_Y, grid, how_many_targets, lul); } - } else{ + } else { for (int i = *x_start; i < *x_start + laenge; i++) { + if (*return_code == 1) { + return 0; + } if (i >= GRID_GROESSE_X - laenge/2+1) { *x_start = laenge/2; - return; + return 0; } grid[*y_start][i] = INFILL_X_PIPE; printf("\33[H\033[J"); - print_grid(GRID_GROESSE_X, GRID_GROESSE_Y, grid, how_many_targets); + *return_code = print_grid(GRID_GROESSE_X, GRID_GROESSE_Y, grid, how_many_targets, lul); } } *x_start += laenge; + return 0; } -void generate_pipe_y(int GRID_GROESSE_X, int GRID_GROESSE_Y, char **grid, int *x_start, int *y_start, int laenge, int how_many_targets) { - if(laenge < 0){ +int generate_pipe_y(int GRID_GROESSE_X, int GRID_GROESSE_Y, char **grid, int *x_start, int *y_start, int laenge, int how_many_targets, int *return_code, int *lul) { + if (laenge < 0){ for (int i = *y_start; i > *y_start + laenge/2; i--) { + if (*return_code == 1) { + return 0; + } if (i <= -laenge/2) { *y_start = GRID_GROESSE_Y + laenge/2; - return; + return 0; } grid[i][*x_start] = INFILL_Y_PIPE; printf("\33[H\033[J"); - print_grid(GRID_GROESSE_X, GRID_GROESSE_Y, grid, how_many_targets); + *return_code = print_grid(GRID_GROESSE_X, GRID_GROESSE_Y, grid, how_many_targets, lul); } } else{ for (int i = *y_start; i < *y_start + laenge/2; i++) { + if (*return_code == 1) { + return 0; + } if (i >= (GRID_GROESSE_Y / 2)*2 - 1) { *y_start = laenge/2; - return; + return 0; } grid[i][*x_start] = INFILL_Y_PIPE; printf("\33[H\033[J"); - print_grid(GRID_GROESSE_X, GRID_GROESSE_Y, grid, how_many_targets); + *return_code = print_grid(GRID_GROESSE_X, GRID_GROESSE_Y, grid, how_many_targets, lul); } } - *y_start += laenge/2; + return 0; } void generate_target(int GRID_GROESSE_X, int GRID_GROESSE_Y, char **grid, int *x_start, int *y_start, int laenge) { @@ -267,7 +285,7 @@ void generate_target(int GRID_GROESSE_X, int GRID_GROESSE_Y, char **grid, int *x int pipes(int GRID_GROESSE_X, int GRID_GROESSE_Y) { //int main() { // system("chcp 65001 >null"); -// int GRID_GROESSE_X = 120; // x:y -> 2:1 for a square looking grid +// int GRID_GROESSE_X = 100; // x:y -> 2:1 for a square looking grid // int GRID_GROESSE_Y = 60; int x_start = GRID_GROESSE_X / 2; @@ -276,6 +294,8 @@ int pipes(int GRID_GROESSE_X, int GRID_GROESSE_Y) { int max_l = MAX_LAENGE_PIPE + 1 - MIN_LAENGE_PIPE; int min_l = MIN_LAENGE_PIPE - 1; int color_c_p = COLOR_CHANGING_PROBABILITY + 1; + int return_code = 0; + int lul = 0; srand(time(NULL)); random_color(); @@ -291,14 +311,14 @@ int pipes(int GRID_GROESSE_X, int GRID_GROESSE_Y) { } } - int richtungswechsler = 1; + // int richtungswechsler = 1; int how_many_targets = 3; for (int i = 1; i <= how_many_targets; i++) { generate_target(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge); } - generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, 1, how_many_targets); + return_code = generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, 1, how_many_targets, &return_code, &lul); - while (!DEBUGGER_RANDOM) { + if (!DEBUGGER_RANDOM) { while (!AUTOMATISCH) { if ((rand() %color_c_p) <= 1) { @@ -313,50 +333,50 @@ int pipes(int GRID_GROESSE_X, int GRID_GROESSE_Y) { char key_input = (char)getch(); #endif switch (key_input) { - case 'h': generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * -1, how_many_targets); break; - case 'a': generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * -1, how_many_targets); break; - case 'l': generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge, how_many_targets); break; - case 'd': generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge, how_many_targets); break; - case 'j': generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge, how_many_targets); break; - case 's': generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge, how_many_targets); break; - case 'k': generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * -1, how_many_targets); break; - case 'w': generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * -1, how_many_targets); break; + case 'h': generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * -1, how_many_targets, &return_code, &lul); break; + case 'a': generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * -1, how_many_targets, &return_code, &lul); break; + case 'l': generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge, how_many_targets, &return_code, &lul); break; + case 'd': generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge, how_many_targets, &return_code, &lul); break; + case 'j': generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge, how_many_targets, &return_code, &lul); break; + case 's': generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge, how_many_targets, &return_code, &lul); break; + case 'k': generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * -1, how_many_targets, &return_code, &lul); break; + case 'w': generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * -1, how_many_targets, &return_code, &lul); break; case 'q': return 0; default: continue; } } - while (AUTOMATISCH) { - if ((rand() %color_c_p) <= 1) { - random_color(); - } - if ((rand() %2)-1) { - laenge = ((rand() %max_l)+min_l); - } else { - laenge = ((rand() %max_l)+min_l)*-1; - } - - if (richtungswechsler == 1) { - generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge, how_many_targets); - richtungswechsler *= -1; - } else { - generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge, how_many_targets); - richtungswechsler *= -1; - } - } - } - - if (DEBUGGER_RANDOM) { - generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge, how_many_targets); - generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge, how_many_targets); - generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge, how_many_targets); - generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * -0.1, how_many_targets); - generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * -1.05, how_many_targets); - generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * -1, how_many_targets); - generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * 0.1, how_many_targets); - generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * 0.9, how_many_targets); - generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge, how_many_targets); +// while (AUTOMATISCH) { +// if ((rand() %color_c_p) <= 1) { +// random_color(); +// } +// if ((rand() %2)-1) { +// laenge = ((rand() %max_l)+min_l); +// } else { +// laenge = ((rand() %max_l)+min_l)*-1; +// } +// +// if (richtungswechsler == 1) { +// generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge, how_many_targets); +// richtungswechsler *= -1; +// } else { +// generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge, how_many_targets); +// richtungswechsler *= -1; +// } +// } +// } +// +// if (DEBUGGER_RANDOM) { +// generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge, how_many_targets); +// generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge, how_many_targets); +// generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge, how_many_targets); +// generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * -0.1, how_many_targets); +// generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * -1.05, how_many_targets); +// generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * -1, how_many_targets); +// generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * 0.1, how_many_targets); +// generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * 0.9, how_many_targets); +// generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge, how_many_targets); }