From 6e5d917dca3230f9e6a6e8ad81e87199f8e19185 Mon Sep 17 00:00:00 2001 From: Mojirade18 Date: Mon, 27 Oct 2025 14:46:43 +0100 Subject: [PATCH 1/6] Added new game: Math Rush (Addition Challenge) in Python --- INDEX.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/INDEX.md b/INDEX.md index 42e7341..68d5e9c 100644 --- a/INDEX.md +++ b/INDEX.md @@ -103,3 +103,6 @@ By now we have 2 numbers (variables), you and computer ### 🎯 [Rock–Paper–Scissors](python/rock_paper_scissors/) - Language: Python + +### 🎯 [Typing_test](./Python/typing_speed_game/) +- Language: Python \ No newline at end of file From a237a8b2b7a44da7d86356256ed9e63d83693e00 Mon Sep 17 00:00:00 2001 From: Mojirade18 Date: Mon, 27 Oct 2025 14:56:50 +0100 Subject: [PATCH 2/6] Added new game: Math Rush (Addition Challenge) in Python --- Python/math_rush/README.md | 24 ++++++++++ Python/math_rush/math_rush.py | 88 +++++++++++++++++++++++++++++++++++ 2 files changed, 112 insertions(+) create mode 100644 Python/math_rush/README.md create mode 100644 Python/math_rush/math_rush.py diff --git a/Python/math_rush/README.md b/Python/math_rush/README.md new file mode 100644 index 0000000..705d908 --- /dev/null +++ b/Python/math_rush/README.md @@ -0,0 +1,24 @@ +# Math Rush (Addition Challenge GUI) + +**Language:** Python +**Run:** `python3 math_rush.py` + +## 🎮 Description +Math Rush is a fun and interactive GUI-based math game where players solve random addition problems under time pressure. +You have **10 seconds** to answer each question correctly — how fast can your brain calculate? + +## 🕹️ Controls +- Type the correct answer in the box and press **Enter**. +- Each question has a 10-second countdown. +- Game ends when you’re too slow or answer incorrectly. + +## 📦 Requirements +- Python 3.8+ +- No external libraries (uses Tkinter, included with Python). + +## 🚀 How to Play +1. Run the script: + `python3 math_rush.py` +2. Click **Start Game**. +3. Add the two numbers before time runs out. +4. Try to reach the highest score! diff --git a/Python/math_rush/math_rush.py b/Python/math_rush/math_rush.py new file mode 100644 index 0000000..513fda1 --- /dev/null +++ b/Python/math_rush/math_rush.py @@ -0,0 +1,88 @@ +import tkinter as tk +import random +import threading +import time + +class MathRush: + def __init__(self, root): + self.root = root + self.root.title("🧮 Math Rush - Addition Challenge") + self.root.geometry("400x350") + self.root.config(bg="#f8f8f8") + + self.score = 0 + self.time_left = 10 + self.current_answer = 0 + + self.header = tk.Label(root, text="🧮 Math Rush!", font=("Helvetica", 20, "bold"), bg="#f8f8f8", fg="#333") + self.header.pack(pady=10) + + self.timer_label = tk.Label(root, text="Time left: 10s", font=("Helvetica", 14), fg="#FF5733", bg="#f8f8f8") + self.timer_label.pack() + + self.score_label = tk.Label(root, text="Score: 0", font=("Helvetica", 14), fg="#1E8449", bg="#f8f8f8") + self.score_label.pack() + + self.question_label = tk.Label(root, text="", font=("Helvetica", 22, "bold"), bg="#f8f8f8") + self.question_label.pack(pady=20) + + self.answer_entry = tk.Entry(root, font=("Helvetica", 16), justify="center") + self.answer_entry.pack(pady=5) + self.answer_entry.bind("", self.check_answer) + + self.feedback_label = tk.Label(root, text="", font=("Helvetica", 14, "bold"), bg="#f8f8f8") + self.feedback_label.pack(pady=10) + + self.start_button = tk.Button(root, text="Start Game", font=("Helvetica", 14, "bold"), bg="#3498db", fg="white", command=self.start_game) + self.start_button.pack(pady=10) + + def start_game(self): + self.score = 0 + self.time_left = 10 + self.score_label.config(text=f"Score: {self.score}") + self.start_button.config(state="disabled") + self.feedback_label.config(text="") + self.next_question() + self.update_timer() + + def next_question(self): + a = random.randint(1, 50) + b = random.randint(1, 50) + self.current_answer = a + b + self.question_label.config(text=f"{a} + {b} = ?") + self.answer_entry.delete(0, tk.END) + self.time_left = 10 + self.timer_label.config(text=f"Time left: {self.time_left}s", fg="#FF5733") + + def update_timer(self): + if self.time_left > 0: + self.time_left -= 1 + self.timer_label.config(text=f"Time left: {self.time_left}s") + self.root.after(1000, self.update_timer) + else: + self.feedback_label.config(text="⏰ Time's up!", fg="orange") + self.end_game() + + def check_answer(self, event): + user_input = self.answer_entry.get().strip() + if not user_input.isdigit(): + self.feedback_label.config(text="Enter a valid number!", fg="red") + return + if int(user_input) == self.current_answer: + self.score += 1 + self.score_label.config(text=f"Score: {self.score}") + self.feedback_label.config(text="✅ Correct!", fg="green") + self.next_question() + else: + self.feedback_label.config(text=f"❌ Wrong! Answer was {self.current_answer}", fg="red") + self.end_game() + + def end_game(self): + self.question_label.config(text="Game Over!") + self.start_button.config(state="normal") + self.feedback_label.config(text=f"Final Score: {self.score}", fg="#333") + +if __name__ == "__main__": + root = tk.Tk() + game = MathRush(root) + root.mainloop() From 173eadf64ed083dfd63b137eb478fce5f01ccbd6 Mon Sep 17 00:00:00 2001 From: Mojirade18 Date: Mon, 27 Oct 2025 15:12:36 +0100 Subject: [PATCH 3/6] Added new game: Math Rush (Addition Challenge) in Python --- INDEX.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/INDEX.md b/INDEX.md index 68d5e9c..e66ef61 100644 --- a/INDEX.md +++ b/INDEX.md @@ -105,4 +105,7 @@ By now we have 2 numbers (variables), you and computer - Language: Python ### 🎯 [Typing_test](./Python/typing_speed_game/) -- Language: Python \ No newline at end of file +- Language: Python + +### 🧮 [Math Rush (Addition Challenge)](./Python/math_rush/) +- Language: Python From 65c4f6189eff698943b7dd307653b64af893cc54 Mon Sep 17 00:00:00 2001 From: Mojirade18 Date: Mon, 27 Oct 2025 15:18:26 +0100 Subject: [PATCH 4/6] Fix syntax error in update_index.py (separate imports) --- update_index.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/update_index.py b/update_index.py index 7b76137..e675673 100644 --- a/update_index.py +++ b/update_index.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 -import os re +import os +import re from pathlib import Path def get_game_description(game_path): From 19d7a5006a48339cc642f4b901b35d7855c2048e Mon Sep 17 00:00:00 2001 From: Mojirade18 Date: Mon, 27 Oct 2025 15:24:22 +0100 Subject: [PATCH 5/6] Fix syntax error in update_index.py (separate imports) --- INDEX.md | 2 +- Python/math_rush/{math_rush.py => main.py} | 0 update_index.py | 3 +-- 3 files changed, 2 insertions(+), 3 deletions(-) rename Python/math_rush/{math_rush.py => main.py} (100%) diff --git a/INDEX.md b/INDEX.md index e66ef61..72472f9 100644 --- a/INDEX.md +++ b/INDEX.md @@ -107,5 +107,5 @@ By now we have 2 numbers (variables), you and computer ### 🎯 [Typing_test](./Python/typing_speed_game/) - Language: Python -### 🧮 [Math Rush (Addition Challenge)](./Python/math_rush/) +### 🎯 [Math Rush (Addition Challenge)](./Python/math_rush/) - Language: Python diff --git a/Python/math_rush/math_rush.py b/Python/math_rush/main.py similarity index 100% rename from Python/math_rush/math_rush.py rename to Python/math_rush/main.py diff --git a/update_index.py b/update_index.py index e675673..7b76137 100644 --- a/update_index.py +++ b/update_index.py @@ -1,7 +1,6 @@ #!/usr/bin/env python3 -import os -import re +import os re from pathlib import Path def get_game_description(game_path): From cc212dc08b4f9f01fcc38409f9ff06864713b7bf Mon Sep 17 00:00:00 2001 From: Mojirade18 Date: Mon, 27 Oct 2025 15:27:57 +0100 Subject: [PATCH 6/6] Fix syntax error --- update_index.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/update_index.py b/update_index.py index 7b76137..e675673 100644 --- a/update_index.py +++ b/update_index.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 -import os re +import os +import re from pathlib import Path def get_game_description(game_path):