mirror of
https://github.com/Soccera1/agg.git
synced 2025-09-19 13:18:38 +02:00
still broken don't use
This commit is contained in:
parent
8d7b0d2405
commit
1572f88af4
3 changed files with 29 additions and 6 deletions
BIN
bin/agg
Executable file
BIN
bin/agg
Executable file
Binary file not shown.
BIN
obj/agg.o
Normal file
BIN
obj/agg.o
Normal file
Binary file not shown.
35
src/agg.c
35
src/agg.c
|
@ -6,7 +6,9 @@
|
|||
#include <string.h>
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue