diff --git a/Games/Molecule_builder/README.md b/Games/Molecule_builder/README.md new file mode 100644 index 0000000000..671c111c6b --- /dev/null +++ b/Games/Molecule_builder/README.md @@ -0,0 +1,23 @@ +# Molecule Builder Game + +## Description +"Molecule Builder" is an educational and puzzle-solving game that challenges players to construct various molecules from individual atoms, while adhering to chemical formulas. This interactive game provides an enjoyable way to learn chemistry concepts and have fun at the same time. + +## Features +- Construct molecules using hydrogen (H) and oxygen (O) atoms. +- Multiple levels with increasing complexity and different target molecules. +- Scoring based on accuracy and completion time. +- User-friendly interface with a canvas for molecule construction. +- Educational gameplay to learn about molecular composition. +- Timer for added challenge. +- Engaging puzzles to test your chemistry knowledge. + +## Game Logic and Description +For a detailed overview of the game logic and a description, please see the [Game Logic and Description](GAME_LOGIC_AND_DESCRIPTION.md) file. + +## Getting Started +To get started with the game, follow these steps: + +1. Clone this repository to your local machine. +2. Run the game using Python (requires Tkinter). + diff --git a/Games/Molecule_builder/assets/images/molecule_builder.png b/Games/Molecule_builder/assets/images/molecule_builder.png new file mode 100644 index 0000000000..697a9d9738 Binary files /dev/null and b/Games/Molecule_builder/assets/images/molecule_builder.png differ diff --git a/Games/Molecule_builder/molecule_builder.py b/Games/Molecule_builder/molecule_builder.py new file mode 100644 index 0000000000..d4d98fe852 --- /dev/null +++ b/Games/Molecule_builder/molecule_builder.py @@ -0,0 +1,35 @@ +import tkinter as tk + +class MoleculeBuilder: + def __init__(self, root): + self.root = root + self.root.title("Molecule Builder") + + self.canvas = tk.Canvas(self.root, width=400, height=400) + self.canvas.pack() + + self.elements = { + "H": {"color": "red", "count": 0}, + "O": {"color": "blue", "count": 0} + } + + self.canvas.bind("", self.add_element) + + def add_element(self, event): + x, y = event.x, event.y + element = "H" if self.elements["H"]["count"] < 2 else "O" + + if self.elements[element]["count"] < 2: + self.elements[element]["count"] += 1 + self.canvas.create_oval(x - 10, y - 10, x + 10, y + 10, fill=self.elements[element]["color"]) + if self.elements["H"]["count"] == 2 and self.elements["O"]["count"] == 1: + self.check_molecule() + + def check_molecule(self): + if self.elements["H"]["count"] == 2 and self.elements["O"]["count"] == 1: + self.canvas.create_text(200, 200, text="You built water (H2O)!", fill="green", font=("Helvetica", 16)) + +if __name__ == "__main__": + root = tk.Tk() + app = MoleculeBuilder(root) + root.mainloop() diff --git a/README.md b/README.md index d81cb0fbeb..d242a80dea 100644 --- a/README.md +++ b/README.md @@ -495,6 +495,7 @@ This repository also provides one such platforms where contributers come over an | 383 | [Puzzel_Winner](https://github.com/kunjgit/GameZone/tree/main/Games/Puzzel_Winner)| | 384 | [Emoji_Intruder](https://github.com/kunjgit/GameZone/tree/main/Games/Emoji_Intruder)| | 385 | [Guess The Weapon](https://github.com/kunjgit/GameZone/tree/main/Games/Guess_The_Weapon)| +| 386 | [Guess The Weapon](https://github.com/kunjgit/GameZone/tree/main/Games/Molecule_builder)| diff --git a/assets/images/molecule_builder.png b/assets/images/molecule_builder.png new file mode 100644 index 0000000000..697a9d9738 Binary files /dev/null and b/assets/images/molecule_builder.png differ