2025-05-22 00:47:42 +10:00
|
|
|
// Made with GNU/Linux
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdbool.h>
|
2025-05-22 16:15:47 +10:00
|
|
|
#include <time.h>
|
|
|
|
#include <stdlib.h>
|
2025-05-22 00:47:42 +10:00
|
|
|
int main(void) {
|
2025-05-22 16:15:47 +10:00
|
|
|
srand(time(NULL));
|
2025-05-22 00:47:42 +10:00
|
|
|
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");
|
|
|
|
int tempInput;
|
|
|
|
bool tutorial;
|
|
|
|
if (scanf ("%d", &tempInput) == 1) {
|
|
|
|
tutorial = tempInput; }
|
|
|
|
if (tutorial) {
|
|
|
|
printf ("OK! Lets continue.\n");
|
|
|
|
} else {
|
|
|
|
printf ("TODO\n"); }
|
2025-05-22 16:15:47 +10:00
|
|
|
|
2025-05-22 16:59:23 +10:00
|
|
|
int playtime;
|
|
|
|
printf ("How long would you like to play for? Answer in seconds.\n");
|
|
|
|
scanf ("%d", &playtime);
|
|
|
|
|
|
|
|
time_t unix_time;
|
|
|
|
unix_time = time(NULL);
|
|
|
|
int end_time = unix_time + playtime;
|
|
|
|
|
|
|
|
int score = 0;
|
|
|
|
// int qa;
|
|
|
|
// int tl;
|
|
|
|
// int st;
|
|
|
|
// I can't remember what the fuck these are for
|
|
|
|
|
|
|
|
while (unix_time < end_time) {
|
|
|
|
float num1 = rand() % 10 + 1;
|
|
|
|
float num2 = rand() % 10 + 1;
|
|
|
|
int type = rand() % 4 + 1;
|
|
|
|
float result;
|
|
|
|
float answer;
|
|
|
|
|
|
|
|
// DEBUG
|
|
|
|
printf("%g, %g and %d\n", num1, num2, type);
|
|
|
|
|
|
|
|
if (type == 1) {
|
|
|
|
printf ("Add %g and %g\n", num1, num2);
|
|
|
|
result = num1 + num2;
|
|
|
|
scanf ("%g", &answer);
|
|
|
|
unix_time = time(NULL);
|
|
|
|
} else if (type == 2) {
|
|
|
|
printf ("Divide %g by %g\n", num1, num2);
|
|
|
|
result = num1 / num2;
|
|
|
|
scanf ("%g", &answer);
|
|
|
|
unix_time = time(NULL);
|
|
|
|
} else if (type == 3) {
|
|
|
|
printf ("Subtract %g from %g\n", num2, num1);
|
|
|
|
result = num1 - num2;
|
|
|
|
scanf ("%g", &answer);
|
|
|
|
unix_time = time(NULL);
|
|
|
|
} else if (type == 4) {
|
|
|
|
printf ("Multiply %g by %g\n", num1, num2);
|
|
|
|
result = num1 * num2;
|
|
|
|
scanf ("%g", &answer);
|
|
|
|
unix_time = time(NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (result == answer) {
|
|
|
|
printf ("Correct!\n");
|
|
|
|
score++;
|
|
|
|
} else {
|
|
|
|
printf ("Incorrect!\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
// DEBUG
|
|
|
|
printf ("Result is %g\n", result);
|
2025-05-22 16:15:47 +10:00
|
|
|
}
|
|
|
|
|
2025-05-22 16:59:23 +10:00
|
|
|
printf ("Your score is %d!\n", score);
|
|
|
|
|
2025-05-22 00:47:42 +10:00
|
|
|
return 0;
|
|
|
|
}
|