diff --git a/Game_Development/Fidget Spinner/Readme.md b/Game_Development/Fidget Spinner/Readme.md new file mode 100644 index 0000000000..3ac44961f1 --- /dev/null +++ b/Game_Development/Fidget Spinner/Readme.md @@ -0,0 +1,38 @@ +# Fidget Spinner Game 🎮 + +## 🎯 Objective + +The **Fidget Spinner Game** is a simple and fun simulation of a fidget spinner created using Python's `turtle` graphics library. The goal is to spin the fidget spinner by pressing the space bar and watch the colorful spinner slow down gradually as it rotates. + +--- + +**Prerequisite**: Install `Python` + +Before running the code, make sure you have Python installed on your system. No additional libraries are needed, as the game uses Python's built-in `turtle` module. + +## 🚀 How to Play: + +1. **Press the space bar** to "flick" the fidget spinner and make it spin. +2. **Watch the spinner** slow down as it rotates through three colored dots (red, green, and blue). +3. **Keep pressing the space bar** to keep the spinner turning faster. +4. The game is a simple, visually soothing simulation – enjoy watching the spinner! + +--- + +## 📝 Features: + +- **Simple Controls**: Press the space bar to flick the spinner and increase its speed. +- **Smooth Animation**: The spinner rotates and slows down smoothly over time. +- **Colorful Design**: The spinner consists of three colored dots (red, green, and blue) arranged in a triangle. +- **Turtle Graphics**: The game is built using Python's `turtle` graphics library, providing an interactive visual experience. + +--- + +## 💻 Running the Game: + +1. **Download or clone** the game code to your local machine. +2. **Run the game** using the command: + ```bash + python main.py + ``` +3. Press the space bar to start spinning the fidget spinner and enjoy! diff --git a/Game_Development/Fidget Spinner/main.py b/Game_Development/Fidget Spinner/main.py new file mode 100644 index 0000000000..f8060f3372 --- /dev/null +++ b/Game_Development/Fidget Spinner/main.py @@ -0,0 +1,36 @@ +from turtle import * +state = {'turn': 0} +def spinner(): + clear() + angle = state['turn']/10 + right(angle) + forward(100) + dot(120, 'red') + back(100) + right(120) + forward(100) + dot(120, 'green') + back(100) + right(120) + forward(100) + dot(120, 'blue') + back(100) + right(120) + update() +def animate(): + if state['turn']>0: + state['turn']-=1 + + spinner() + ontimer(animate, 20) +def flick(): + state['turn']+=10 + +setup(420, 420, 370, 0) +hideturtle() +tracer(False) +width(20) +onkey(flick, 'space') +listen() +animate() +done() diff --git a/Project-Structure.md b/Project-Structure.md index 61d26b3904..98d1efc296 100644 --- a/Project-Structure.md +++ b/Project-Structure.md @@ -500,6 +500,8 @@ * [Crossword](Game_Development/Crossword%20Game/crossword.py) * Dice Rolling Simulator * [Main3](Game_Development/Dice_rolling_simulator/main3.py) + * Fidget Spinner + * [Main](Game_Development/Fidget%20Spinner/main.py) * Flappy Bird * [Main](Game_Development/Flappy_Bird/main.py) * Hangman-Main