mirror of
https://github.com/Soccera1/agg.git
synced 2026-02-04 04:03:40 +01:00
Compare commits
4 commits
51e7266911
...
34169274f4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
34169274f4 | ||
|
|
a01f7a6699 | ||
|
|
ce21da8661 | ||
|
|
b3d3bc91ea |
5 changed files with 8 additions and 288 deletions
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
|
|
@ -19,7 +19,7 @@ jobs:
|
|||
run: sudo apt-get update && sudo apt-get install -y build-essential
|
||||
|
||||
- name: Build project for Linux
|
||||
run: make all
|
||||
run: LDFLAGS="-static" make all
|
||||
working-directory: ${{ github.workspace }}
|
||||
|
||||
- name: Upload Linux artifact
|
||||
|
|
|
|||
6
Makefile
6
Makefile
|
|
@ -1,6 +1,8 @@
|
|||
# Compiler and flags
|
||||
CC = gcc
|
||||
CFLAGS = -Wall -Wextra -std=c99 -O3 -flto
|
||||
EXTRA_CFLAGS ?=
|
||||
CFLAGS ?= -Wall -Wextra -std=c99 -pedantic -O3 -flto $(EXTRA_CFLAGS)
|
||||
LDFLAGS ?=
|
||||
DEBUG_FLAGS = -g -DDEBUG
|
||||
|
||||
# Directories
|
||||
|
|
@ -29,7 +31,7 @@ $(OBJDIR)/%.o: $(SRCDIR)/%.c | $(OBJDIR)
|
|||
|
||||
# Link executable
|
||||
$(TARGET): $(OBJECTS) | $(BINDIR)
|
||||
$(CC) $(OBJECTS) -o $@
|
||||
$(CC) $(LDFLAGS) $(OBJECTS) -o $@
|
||||
|
||||
# Debug build
|
||||
debug: CFLAGS += $(DEBUG_FLAGS)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,3 @@
|
|||
Hi! This is a game designed for AgnoxGD.
|
||||
|
||||
This game is licensed under the GNU Affero Public License v3.
|
||||
|
||||
also I probably won't update the html version like ever unless claude can 1 shot it 🥀
|
||||
|
||||
because I don't know html lmao
|
||||
|
|
|
|||
|
|
@ -152,12 +152,12 @@ int main(void) {
|
|||
if (score >= 1) {
|
||||
printf ("Great job, %s!\n", username);
|
||||
} else {
|
||||
printf ("try again!, %s.\n", username);
|
||||
printf ("Try again!, %s.\n", username);
|
||||
}
|
||||
if (accuracytype == 1) {
|
||||
printf ("you got an accuracy of %d%%!\n", (int)accuracy);
|
||||
printf ("You got an accuracy of %d%%!\n", (int)accuracy);
|
||||
} else {
|
||||
printf ("you got an accuracy of %g%%!\n", accuracy);
|
||||
printf ("You got an accuracy of %g%%!\n", accuracy);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
278
src/agg.html
278
src/agg.html
|
|
@ -1,278 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Agg Math Game</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: monospace;
|
||||
background: #000;
|
||||
color: #0f0;
|
||||
padding: 20px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
.container {
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
input {
|
||||
background: #000;
|
||||
color: #0f0;
|
||||
border: 1px solid #0f0;
|
||||
padding: 5px;
|
||||
font-family: monospace;
|
||||
margin: 5px 0;
|
||||
}
|
||||
button {
|
||||
background: #000;
|
||||
color: #0f0;
|
||||
border: 1px solid #0f0;
|
||||
padding: 10px 20px;
|
||||
font-family: monospace;
|
||||
cursor: pointer;
|
||||
margin: 5px;
|
||||
}
|
||||
button:hover {
|
||||
background: #0f0;
|
||||
color: #000;
|
||||
}
|
||||
.output {
|
||||
white-space: pre-line;
|
||||
margin: 10px 0;
|
||||
}
|
||||
.input-group {
|
||||
margin: 10px 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div id="output" class="output"></div>
|
||||
<div id="input-area" class="input-group"></div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Global variables to maintain state
|
||||
let currentStep = 0;
|
||||
let tutorial = false;
|
||||
let accuracytype = 0;
|
||||
let playtime = 0;
|
||||
let number_length = 0;
|
||||
let end_time = 0;
|
||||
let score = 0;
|
||||
let questioncount = 0;
|
||||
let currentResult = 0;
|
||||
let gameRunning = false;
|
||||
|
||||
function print(text) {
|
||||
document.getElementById('output').innerHTML += text + '\n';
|
||||
}
|
||||
|
||||
function clearInput() {
|
||||
document.getElementById('input-area').innerHTML = '';
|
||||
}
|
||||
|
||||
function createInput(placeholder, callback) {
|
||||
const inputArea = document.getElementById('input-area');
|
||||
const input = document.createElement('input');
|
||||
input.type = 'text';
|
||||
input.placeholder = placeholder;
|
||||
input.addEventListener('keypress', function(e) {
|
||||
if (e.key === 'Enter') {
|
||||
const value = input.value;
|
||||
callback(value);
|
||||
}
|
||||
});
|
||||
inputArea.appendChild(input);
|
||||
input.focus();
|
||||
}
|
||||
|
||||
function getUsername() {
|
||||
// Browser equivalent of getenv("USER")
|
||||
return "Player";
|
||||
}
|
||||
|
||||
function randMod(max) {
|
||||
return Math.floor(Math.random() * max);
|
||||
}
|
||||
|
||||
function time() {
|
||||
return Math.floor(Date.now() / 1000);
|
||||
}
|
||||
|
||||
function isvalidnumber(entered) {
|
||||
let valid = 1;
|
||||
for (let i = 0; i < entered.length; i++) {
|
||||
const char = entered[i];
|
||||
switch (char) {
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
case '.':
|
||||
case '-':
|
||||
break;
|
||||
default:
|
||||
valid = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
|
||||
function startGame() {
|
||||
const username = getUsername();
|
||||
print(`Hello ${username}!`);
|
||||
print("This is a game written for AgnoxGD.");
|
||||
print("Would you like to see a tutorial");
|
||||
print("Type 1 for no, or 0 for yes.");
|
||||
|
||||
createInput("Enter 0 or 1", function(input) {
|
||||
if (isvalidnumber(input)) {
|
||||
const tempInput = parseInt(input);
|
||||
tutorial = tempInput;
|
||||
} else {
|
||||
print("Error! An invalid character was entered.");
|
||||
return;
|
||||
}
|
||||
|
||||
clearInput();
|
||||
|
||||
if (tutorial) {
|
||||
print("OK! Lets continue.");
|
||||
} else {
|
||||
print("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!");
|
||||
}
|
||||
|
||||
askAccuracyType();
|
||||
});
|
||||
}
|
||||
|
||||
function askAccuracyType() {
|
||||
print("Would you like your accuracy as a float or as an int? Type 0 for float or 1 for int.");
|
||||
createInput("Enter 0 or 1", function(input) {
|
||||
if (isvalidnumber(input)) {
|
||||
accuracytype = parseInt(input);
|
||||
} else {
|
||||
print("Error! An invalid character was entered.");
|
||||
return;
|
||||
}
|
||||
clearInput();
|
||||
askPlaytime();
|
||||
});
|
||||
}
|
||||
|
||||
function askPlaytime() {
|
||||
print("\nHow long would you like to play for? Answer in seconds.");
|
||||
createInput("Enter seconds", function(input) {
|
||||
playtime = parseInt(input);
|
||||
clearInput();
|
||||
askNumberLength();
|
||||
});
|
||||
}
|
||||
|
||||
function askNumberLength() {
|
||||
print("Please enter maximum possible number");
|
||||
createInput("Enter max number", function(input) {
|
||||
number_length = parseInt(input);
|
||||
clearInput();
|
||||
startGameLoop();
|
||||
});
|
||||
}
|
||||
|
||||
function startGameLoop() {
|
||||
const unix_time = time();
|
||||
end_time = unix_time + playtime;
|
||||
score = 0;
|
||||
questioncount = 0;
|
||||
gameRunning = true;
|
||||
|
||||
nextQuestion();
|
||||
}
|
||||
|
||||
function nextQuestion() {
|
||||
let unix_time = time();
|
||||
|
||||
if (unix_time >= end_time) {
|
||||
endGame();
|
||||
return;
|
||||
}
|
||||
|
||||
const num1 = randMod(number_length) + 1;
|
||||
const num2 = randMod(number_length) + 1;
|
||||
const type = randMod(4) + 1;
|
||||
let result;
|
||||
|
||||
if (type == 1) {
|
||||
print(`Add ${num1} and ${num2}`);
|
||||
result = num1 + num2;
|
||||
} else if (type == 2) {
|
||||
print(`Divide ${num1} by ${num2}`);
|
||||
result = num1 / num2;
|
||||
} else if (type == 3) {
|
||||
print(`Subtract ${num1} from ${num2}`);
|
||||
result = num1 - num2;
|
||||
} else if (type == 4) {
|
||||
print(`Multiply ${num1} by ${num2}`);
|
||||
result = num1 * num2;
|
||||
}
|
||||
|
||||
// Update time after generating question (like C version)
|
||||
unix_time = time();
|
||||
currentResult = result;
|
||||
questioncount++;
|
||||
|
||||
createInput("Enter your answer", function(entered) {
|
||||
if (isvalidnumber(entered)) {
|
||||
const answer = parseFloat(entered);
|
||||
|
||||
if (currentResult == answer) {
|
||||
print("Correct!");
|
||||
score++;
|
||||
} else {
|
||||
print(`Incorrect! The correct answer is ${currentResult}.`);
|
||||
}
|
||||
} else {
|
||||
print("Error! An invalid character was entered.");
|
||||
return;
|
||||
}
|
||||
|
||||
clearInput();
|
||||
setTimeout(nextQuestion, 10); // Small delay to prevent blocking
|
||||
});
|
||||
}
|
||||
|
||||
function endGame() {
|
||||
gameRunning = false;
|
||||
const username = getUsername();
|
||||
|
||||
const accuracy = score / questioncount * 100;
|
||||
|
||||
print(`Your score is ${score}!`);
|
||||
if (score >= 1) {
|
||||
print(`Great job, ${username}!`);
|
||||
} else {
|
||||
print(`Try again!, ${username}.`);
|
||||
}
|
||||
|
||||
if (accuracytype == 1) {
|
||||
print(`You got an accuracy of ${Math.floor(accuracy)}%!`);
|
||||
} else {
|
||||
print(`You got an accuracy of ${accuracy}%!`);
|
||||
}
|
||||
}
|
||||
|
||||
// Start the game when page loads
|
||||
window.onload = function() {
|
||||
startGame();
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Reference in a new issue