diff --git a/chess/code.py b/Game-Galore/chess.py similarity index 100% rename from chess/code.py rename to Game-Galore/chess.py diff --git a/chess/readme.md b/Game-Galore/chessreadme.md similarity index 100% rename from chess/readme.md rename to Game-Galore/chessreadme.md diff --git a/Game-Galore/memory matchinggame.py b/Game-Galore/memory matchinggame.py new file mode 100644 index 0000000..acb9d3a --- /dev/null +++ b/Game-Galore/memory matchinggame.py @@ -0,0 +1,80 @@ +import tkinter as tk +import random +import time + +class MemoryGame: + def __init__(self, root): + self.root = root + self.root.title("Memory Matching Game") + self.buttons = [] + self.first = None + self.second = None + self.pairs_found = 0 + self.card_values = self.generate_card_values() + + self.create_board() + + def generate_card_values(self): + """Generates pairs of card values and shuffles them.""" + values = list(range(1, 9)) * 2 # Create pairs from 1 to 8 + random.shuffle(values) # Shuffle the values + return values + + def create_board(self): + """Creates the game board with buttons.""" + for i in range(4): # 4 rows + row = [] + for j in range(4): # 4 columns + button = tk.Button(self.root, text="", width=8, height=4, + command=lambda row=i, col=j: self.on_button_click(row, col)) + button.grid(row=i, column=j) + row.append(button) + self.buttons.append(row) + + def on_button_click(self, row, col): + """Handles the logic when a card is clicked.""" + if self.first and self.second: + return # Don't allow more than two selections at a time + + button = self.buttons[row][col] + + if not button['text']: # Only act if button hasn't been flipped + button['text'] = str(self.card_values[row * 4 + col]) + + if not self.first: + self.first = (row, col) + elif not self.second: + self.second = (row, col) + + self.root.after(1000, self.check_match) # Wait 1 second and check + + def check_match(self): + """Checks if two selected cards are a match.""" + first_row, first_col = self.first + second_row, second_col = self.second + + first_value = self.card_values[first_row * 4 + first_col] + second_value = self.card_values[second_row * 4 + second_col] + + if first_value == second_value: + self.pairs_found += 1 + else: + self.buttons[first_row][first_col]['text'] = "" + self.buttons[second_row][second_col]['text'] = "" + + self.first = None + self.second = None + + if self.pairs_found == 8: + self.show_win_message() + + def show_win_message(self): + """Displays a win message when all pairs are found.""" + win_message = tk.Label(self.root, text="Congratulations! You've found all pairs!", font=('Arial', 16)) + win_message.grid(row=4, column=0, columnspan=4) + +# Running the game +if __name__ == "__main__": + root = tk.Tk() + game = MemoryGame(root) + root.mainloop() diff --git a/Game-Galore/memorymatching.md b/Game-Galore/memorymatching.md new file mode 100644 index 0000000..6f4dee7 --- /dev/null +++ b/Game-Galore/memorymatching.md @@ -0,0 +1,70 @@ +# Memory Matching Game + +This is a simple **Memory Matching Game** built using Python and the `tkinter` library. The game involves finding pairs of matching cards on a 4x4 grid. It's easy to play and enjoyable for players of all ages. + +## How to Play + +1. The game board consists of a 4x4 grid of 16 cards (8 pairs). +2. Click on any two cards to flip them over. +3. If the two cards match, they will stay visible. +4. If the two cards don't match, they will flip back after a short delay. +5. The game ends when all pairs are matched, and a congratulatory message appears. + +## Features + +- A 4x4 grid layout for the game. +- Randomized shuffling of card pairs. +- Matching pairs will stay visible; mismatched pairs flip back. +- End-game message when all pairs are found. + +## Prerequisites + +To run the Memory Matching Game, you need: +- **Python 3.x** +- **Tkinter** (comes pre-installed with most Python versions) + +## Installation + +1. **Clone the repository** or download the script directly: + ```bash + git clone https://github.com/yourusername/memory-matching-game.git + cd memory-matching-game + ``` + +2. **Run the Python script**: + ```bash + python memory_matching_game.py + ``` + +3. The game window will launch, and you can start playing by clicking on any two cards. + +## Customization Options + +Feel free to make the game your own: +- Change the grid size (e.g., 6x6, 8x8) for more cards. +- Adjust card values or images for personalization. +- Add a timer for an additional challenge. +- Implement a scoring system to keep track of performance. +- Introduce multiple levels with increasing difficulty. + +## Game Screenshot + +*Include a screenshot of the game running.* + +## License + +This project is licensed under the MIT License. Feel free to use, modify, and distribute it as you wish. + +## Contributing + +If you'd like to contribute to this project: +1. Fork the repository. +2. Create a new branch (`git checkout -b feature-name`). +3. Commit your changes (`git commit -m 'Add some feature'`). +4. Push the branch (`git push origin feature-name`). +5. Open a pull request. + +--- + + +