remove print_ascii()
This commit is contained in:
parent
3830e03a7a
commit
52087d0d71
|
|
@ -1,8 +0,0 @@
|
||||||
────────────────────────────────
|
|
||||||
╔════╗ ╔═══╗ ╔═══╗ ╔═══╗
|
|
||||||
║╔╗╔╗║ ║╔═╗║ ║╔═╗║ ║╔═╗║
|
|
||||||
╚╝║║╚╝ ║╚═╝║ ║║ ║║ ║╚══╗
|
|
||||||
║║ ║╔╗╔╝ ║║ ║║ ╚══╗║
|
|
||||||
╔╝╚╗ ║║║╚╗ ║╚═╝║ ║╚═╝║
|
|
||||||
╚══╝ ╚╝╚═╝ ╚═══╝ ╚═══╝
|
|
||||||
────────────────────────────────
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
──────────────────────────────────────────
|
|
||||||
╔╗╔╗╔╗╔══╗╔═╗ ╔╗╔═╗ ╔╗╔═══╗╔═══╗╔╗╔╗
|
|
||||||
║║║║║║╚╣╠╝║║╚╗║║║║╚╗║║║╔══╝║╔═╗║║║║║
|
|
||||||
║║║║║║ ║║ ║╔╗╚╝║║╔╗╚╝║║╚══╗║╚═╝║║║║║
|
|
||||||
║╚╝╚╝║ ║║ ║║╚╗║║║║╚╗║║║╔══╝║╔╗╔╝╚╝╚╝
|
|
||||||
╚╗╔╗╔╝╔╣╠╗║║ ║║║║║ ║║║║╚══╗║║║╚╗╔╗╔╗
|
|
||||||
╚╝╚╝ ╚══╝╚╝ ╚═╝╚╝ ╚═╝╚═══╝╚╝╚═╝╚╝╚╝
|
|
||||||
──────────────────────────────────────────
|
|
||||||
34
src/main.c
34
src/main.c
|
|
@ -5,11 +5,27 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
// https://texteditor.com/multiline-text-art/
|
// https://texteditor.com/multiline-text-art/
|
||||||
|
|
||||||
|
const char BANNER[][300] = {
|
||||||
|
" ╔════╗ ╔═══╗ ╔═══╗ ╔═══╗", " ║╔╗╔╗║ ║╔═╗║ ║╔═╗║ ║╔═╗║",
|
||||||
|
" ╚╝║║╚╝ ║╚═╝║ ║║ ║║ ║╚══╗", " ║║ ║╔╗╔╝ ║║ ║║ ╚══╗║",
|
||||||
|
" ╔╝╚╗ ║║║╚╗ ║╚═╝║ ║╚═╝║", " ╚══╝ ╚╝╚═╝ ╚═══╝ ╚═══╝",
|
||||||
|
};
|
||||||
|
|
||||||
|
const char WINNER[][300] = {
|
||||||
|
"──────────────────────────────────────────",
|
||||||
|
" ╔╗╔╗╔╗╔══╗╔═╗ ╔╗╔═╗ ╔╗╔═══╗╔═══╗╔╗╔╗",
|
||||||
|
" ║║║║║║╚╣╠╝║║╚╗║║║║╚╗║║║╔══╝║╔═╗║║║║║",
|
||||||
|
" ║║║║║║ ║║ ║╔╗╚╝║║╔╗╚╝║║╚══╗║╚═╝║║║║║",
|
||||||
|
" ║╚╝╚╝║ ║║ ║║╚╗║║║║╚╗║║║╔══╝║╔╗╔╝╚╝╚╝",
|
||||||
|
" ╚╗╔╗╔╝╔╣╠╗║║ ║║║║║ ║║║║╚══╗║║║╚╗╔╗╔╗",
|
||||||
|
" ╚╝╚╝ ╚══╝╚╝ ╚═╝╚╝ ╚═╝╚═══╝╚╝╚═╝╚╝╚╝",
|
||||||
|
"──────────────────────────────────────────",
|
||||||
|
};
|
||||||
|
|
||||||
static const int EASY_SCORE_DECREMENT = 10;
|
static const int EASY_SCORE_DECREMENT = 10;
|
||||||
static const int MEDIUM_SCORE_DECREMENT = 20;
|
static const int MEDIUM_SCORE_DECREMENT = 20;
|
||||||
static const int LOWER = 1;
|
static const int LOWER = 1;
|
||||||
static const int UPPER = 4;
|
static const int UPPER = 4;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
Easy,
|
Easy,
|
||||||
Medium,
|
Medium,
|
||||||
|
|
@ -36,8 +52,10 @@ int main(int argc, char *argv[]) {
|
||||||
int guess;
|
int guess;
|
||||||
|
|
||||||
clearscreen();
|
clearscreen();
|
||||||
printf(COLOR_CYAN);
|
printf(COLOR_CYAN BAR);
|
||||||
print_ascii("./assets/banner.txt");
|
for (int i = 0; i < 6; i++) {
|
||||||
|
printf("%s\n", BANNER[i]);
|
||||||
|
}
|
||||||
Difficulty diff = get_difficulty();
|
Difficulty diff = get_difficulty();
|
||||||
|
|
||||||
while (level > 0 && level <= 10) {
|
while (level > 0 && level <= 10) {
|
||||||
|
|
@ -103,6 +121,7 @@ void decrement_score(Difficulty diff) {
|
||||||
Difficulty get_difficulty() {
|
Difficulty get_difficulty() {
|
||||||
int choice;
|
int choice;
|
||||||
Difficulty difficulty;
|
Difficulty difficulty;
|
||||||
|
printf(COLOR_GREEN BAR COLOR_OFF);
|
||||||
printf(COLOR_BOLD COLOR_RED " CHOOSE DIFFICULTY\n");
|
printf(COLOR_BOLD COLOR_RED " CHOOSE DIFFICULTY\n");
|
||||||
printf(COLOR_GREEN BAR COLOR_OFF);
|
printf(COLOR_GREEN BAR COLOR_OFF);
|
||||||
printf(COLOR_BOLD "[1]" COLOR_OFF " Easy\n");
|
printf(COLOR_BOLD "[1]" COLOR_OFF " Easy\n");
|
||||||
|
|
@ -121,7 +140,7 @@ Difficulty get_difficulty() {
|
||||||
case 3:
|
case 3:
|
||||||
difficulty = Hard;
|
difficulty = Hard;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf(COLOR_RED "Invalid Choice. Defaulting to Medium\n" COLOR_OFF);
|
printf(COLOR_RED "Invalid Choice. Defaulting to Medium\n" COLOR_OFF);
|
||||||
difficulty = Medium;
|
difficulty = Medium;
|
||||||
break;
|
break;
|
||||||
|
|
@ -132,7 +151,9 @@ Difficulty get_difficulty() {
|
||||||
void level_up() {
|
void level_up() {
|
||||||
if (level == 10) {
|
if (level == 10) {
|
||||||
printf(COLOR_YELLOW);
|
printf(COLOR_YELLOW);
|
||||||
print_ascii("./assets/winner.txt");
|
for (int i = 0; i < 8; i++) {
|
||||||
|
printf("%s\n", WINNER[i]);
|
||||||
|
}
|
||||||
printf(COLOR_OFF);
|
printf(COLOR_OFF);
|
||||||
printf("Congratulations!! You WON the game");
|
printf("Congratulations!! You WON the game");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
@ -149,7 +170,8 @@ void level_down() {
|
||||||
level--;
|
level--;
|
||||||
size -= 3;
|
size -= 3;
|
||||||
} else {
|
} else {
|
||||||
printf("Too many wrong answers!! " COLOR_RED COLOR_BOLD "You Lose!!\n" COLOR_OFF);
|
printf("Too many wrong answers!! " COLOR_RED COLOR_BOLD
|
||||||
|
"You Lose!!\n" COLOR_OFF);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
11
src/utils.c
11
src/utils.c
|
|
@ -8,17 +8,6 @@ void printarr(int a[], int n) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_ascii(char *filename) {
|
|
||||||
char read_string[MAX_LEN];
|
|
||||||
FILE *fptr = NULL;
|
|
||||||
if ((fptr = fopen(filename, "r")) == NULL) {
|
|
||||||
fprintf(stderr, "error opening %s\n", filename);
|
|
||||||
}
|
|
||||||
while (fgets(read_string, sizeof(read_string), fptr) != NULL) {
|
|
||||||
printf("%s", read_string);
|
|
||||||
}
|
|
||||||
fclose(fptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void swap(int a[], int i, int j) {
|
void swap(int a[], int i, int j) {
|
||||||
int tmp = a[i];
|
int tmp = a[i];
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,5 @@
|
||||||
#define COLOR_OFF "\e[m"
|
#define COLOR_OFF "\e[m"
|
||||||
|
|
||||||
void printarr(int a[], int n);
|
void printarr(int a[], int n);
|
||||||
void print_ascii(char *filename);
|
|
||||||
void swap(int a[], int i, int j);
|
void swap(int a[], int i, int j);
|
||||||
void clearscreen();
|
void clearscreen();
|
||||||
|
|
|
||||||
Reference in New Issue