Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

molecule_builder #3007

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Games/Molecule_builder/README.md
Original file line number Diff line number Diff line change
@@ -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).

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions Games/Molecule_builder/molecule_builder.py
Original file line number Diff line number Diff line change
@@ -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("<Button-1>", 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()
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)|

</center>

Expand Down
Binary file added assets/images/molecule_builder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading