clean up code
parent
d38b65d59b
commit
f1ca9b4da6
30
src/main.c
30
src/main.c
|
@ -29,10 +29,12 @@ Datum: 04.12.2024
|
|||
0.2 09.12.2024 Willkommensnachricht
|
||||
0.3 10.12.2024 Meun hinzugefügt
|
||||
0.4 11.12.2024 pipes + easter eggs hinzugefügt
|
||||
0.5 12.12.2024 Windows version fix
|
||||
*/
|
||||
|
||||
#ifdef __linux__
|
||||
int getch(){
|
||||
// getch funktion für linux (für windows in der conio lib)
|
||||
int ch;
|
||||
struct termios oldattr, newattr;
|
||||
|
||||
|
@ -58,7 +60,6 @@ void get_terminal_size_linux(int argc, char **argv, int *width, int *height){
|
|||
*height = w.ws_row;
|
||||
*width = w.ws_col;
|
||||
}
|
||||
|
||||
#elif _WIN32
|
||||
void get_terminal_size_windows(int argc, char **argv, int *width, int *height){
|
||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||
|
@ -75,15 +76,10 @@ void print_line(char line[100], int spaces, char color[5]){
|
|||
printf(" ");
|
||||
}
|
||||
printf("\033[1%sm %s \033[0m\n", color, line);
|
||||
// printf("%s\n", line);
|
||||
}
|
||||
|
||||
void clear_terminal(){
|
||||
#ifdef __linux__
|
||||
printf("\e[1;1H\e[2J");
|
||||
#elif _WIN32
|
||||
system("cls");
|
||||
#endif
|
||||
}
|
||||
|
||||
void sleep_universal(int t){
|
||||
|
@ -119,20 +115,6 @@ void print_wellcome(int terminal_width, int terminal_height){
|
|||
print_line("|_| |_| |_|\\___/ \\__|_| |_|\\___/|_| |_|_|\\___|___/ |_| |_|\\___|_|_| \\___|_| ", spaces, ";37");
|
||||
|
||||
sleep_universal(2);
|
||||
|
||||
/*
|
||||
printf("__ ___ _ _ _ ");
|
||||
printf("\ \ / (_) | | | _____ _ __ ___ _ __ ___ ___ _ __ _____ _ _ __ ___ ");
|
||||
printf(" \ \ /\ / /| | | | |/ / _ \| '_ ` _ \| '_ ` _ \ / _ \ '_ \ |_ / | | | '_ ` _ \ ");
|
||||
printf(" \ V V / | | | | < (_) | | | | | | | | | | | __/ | | | / /| |_| | | | | | |");
|
||||
printf(" \_/\_/ |_|_|_|_|\_\___/|_| |_| |_|_| |_| |_|\___|_| |_| /___|\__,_|_| |_| |_|");
|
||||
printf(" ");
|
||||
printf(" ____ _ _ _ _ _ _ _ __ ");
|
||||
printf("| _ \| |__ ___ | |_| |__ ___ _ __ (_) ___ ___ | | | | ___| |/ _| ___ _ __ ");
|
||||
printf("| |_) | '_ \ / _ \| __| '_ \ / _ \| '_ \| |/ __/ __| | |_| |/ _ \ | |_ / _ \ '__|");
|
||||
printf("| __/| | | | (_) | |_| | | | (_) | | | | | (__\__ \ | _ | __/ | _| __/ | ");
|
||||
printf("|_| |_| |_|\___/ \__|_| |_|\___/|_| |_|_|\___|___/ |_| |_|\___|_|_| \___|_| ");
|
||||
*/
|
||||
}
|
||||
|
||||
void print_game_over(int terminal_width, int terminal_height){
|
||||
|
@ -149,8 +131,6 @@ void print_game_over(int terminal_width, int terminal_height){
|
|||
print_blank_lines(2);
|
||||
print_line("Press a key to contine: ", spaces, ";37");
|
||||
char key_input = (char)getch();
|
||||
// getchar();
|
||||
|
||||
}
|
||||
|
||||
void print_speedrun(int terminal_width, int terminal_height, int speed_time){
|
||||
|
@ -158,7 +138,6 @@ void print_speedrun(int terminal_width, int terminal_height, int speed_time){
|
|||
print_blank_lines((terminal_height - 12) / 2);
|
||||
int spaces = (terminal_width - 70) / 2;
|
||||
|
||||
|
||||
print_line(" _ ____ _ _ ___ _______ _______ __ __ _____ _ _ _____ ", spaces, ";37");
|
||||
print_line(" / \\ / ___| | | |_ _| ____\\ \\ / / ____| \\/ | ____| \\ | |_ _| ", spaces, ";37");
|
||||
print_line(" / _ \\| | | |_| || || _| \\ \\ / /| _| | |\\/| | _| | \\| | | |(_) ", spaces, ";37");
|
||||
|
@ -175,7 +154,6 @@ void print_speedrun(int terminal_width, int terminal_height, int speed_time){
|
|||
print_line("", spaces, ";37");
|
||||
printf("Du brauchtest: %i Sekunden.", speed_time);
|
||||
char key_input = (char)getch();
|
||||
|
||||
}
|
||||
|
||||
void print_menu(int terminal_width, int terminal_height, int line){
|
||||
|
@ -185,7 +163,7 @@ void print_menu(int terminal_width, int terminal_height, int line){
|
|||
int spaces = (terminal_width - 41) / 2;
|
||||
|
||||
print_line("┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓", spaces, (0 <= line && line < 1) ? ";31": ";37");
|
||||
print_line("┃ Ramen Physik ┃", spaces, (0 <= line && line < 1) ? ";31": ";37");
|
||||
print_line("┃ 1 Ramen Physik ┃", spaces, (0 <= line && line < 1) ? ";31": ";37");
|
||||
print_line("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫", spaces, (0 <= line && line < 2) ? ";31": ";37");
|
||||
print_line("┃ Programm 2 ┃", spaces, (1 <= line && line < 2) ? ";31": ";37");
|
||||
print_line("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫", spaces, (1 <= line && line < 3) ? ";31": ";37");
|
||||
|
@ -218,7 +196,6 @@ void print_help(){
|
|||
printf("q \t Um das Programm zu beenden\n");
|
||||
printf("\nDrücke eine Taste um zurück zu kommen\n");
|
||||
char key_input = (char)getch();
|
||||
// getchar();
|
||||
}
|
||||
|
||||
void get_terminal_size(int argc, char **argv, int *width, int *height){
|
||||
|
@ -306,7 +283,6 @@ int main(int argc, char **argv){
|
|||
// Terminal grösse herauslesen
|
||||
get_terminal_size_init(argc, argv, &width, &height);
|
||||
|
||||
|
||||
// print wellcome message
|
||||
print_wellcome(width, height);
|
||||
while(run){
|
||||
|
|
Loading…
Reference in New Issue