diff --git a/bin/agg b/bin/agg new file mode 100755 index 0000000..c531013 Binary files /dev/null and b/bin/agg differ diff --git a/obj/agg.o b/obj/agg.o new file mode 100644 index 0000000..66b9aa2 Binary files /dev/null and b/obj/agg.o differ diff --git a/src/agg.c b/src/agg.c index 3f50202..61bfdef 100644 --- a/src/agg.c +++ b/src/agg.c @@ -6,7 +6,9 @@ #include int main(void) { srand(time(NULL)); - printf ("Hello World!\nThis is a game written for AgnoxGD.\nWould you like to see a tutorial\nType 1 for no, or 0 for yes.\n"); + + char *username = getenv("USER"); + printf ("Hello %s!\nThis is a game written for AgnoxGD.\nWould you like to see a tutorial\nType 1 for no, or 0 for yes.\n", username); int tempInput; bool tutorial; if (scanf ("%d", &tempInput) == 1) { @@ -16,6 +18,10 @@ int main(void) { } else { printf ("Welcome to Agg! This game tests your math skills against the clock.\n\nHow to Play:\n\n1. Set Your Playtime: First, you'll decide how long you want to play by entering a duration in seconds.\n2. Solve Math Problems: Once the game starts, you'll be presented with a series of random math problems: addition, division, subtraction, and multiplication. Your goal is to solve as many as you can before time runs out.\n3. Enter Your Answer: After each problem, type your answer and press Enter. The game will immediately tell you if you're correct or incorrect.\n4. Rack Up Points: For every correct answer, you'll earn a point. Your score will be tallied at the end.\n5. Time's Up! The game ends automatically when your chosen playtime runs out. Good luck, and have fun!\n"); } + int accuracytype; + printf ("Would you like your accuracy as a float or as an int? Type 0 for float or 1 for int.\n"); + scanf ("%d", &accuracytype); + int playtime; printf ("\nHow long would you like to play for? Answer in seconds.\n"); scanf ("%d", &playtime); @@ -29,6 +35,7 @@ int main(void) { int end_time = unix_time + playtime; int score = 0; + int questioncount = 0; while (unix_time < end_time) { float num1 = rand() % number_length + 1; @@ -44,20 +51,18 @@ int main(void) { if (type == 1) { printf ("Add %g and %g\n", num1, num2); result = num1 + num2; - unix_time = time(NULL); } else if (type == 2) { printf ("Divide %g by %g\n", num1, num2); result = num1 / num2; - unix_time = time(NULL); } else if (type == 3) { printf ("Subtract %g from %g\n", num2, num1); result = num1 - num2; - unix_time = time(NULL); } else if (type == 4) { printf ("Multiply %g by %g\n", num1, num2); result = num1 * num2; - unix_time = time(NULL); } + unix_time = time(NULL); + questioncount++; scanf ("%s", entered); int valid = 1; @@ -108,7 +113,25 @@ int main(void) { // printf ("Result is %g\n", result); } - printf ("Your score is %d!\n", score); + float accuracy; + accuracy = score / questioncount; + if (accuracytype == 1) { + accuracy = (int)accuracy * 100; + } else { + accuracy = accuracy * 100; + } + + printf ("Your score is %d!\n", score); + if (score >= 1) { + printf ("Great job, %s!\n", username); + } else { + printf ("Try again!, %s.\n", username); + } + if (accuracytype == 1) { + printf ("You got an accuracy of %d!\n", (int)accuracy); + } else { + printf ("You got an accuracy of %g!\n", accuracy); + } return 0; }