Skip to content

Commit

Permalink
Merge pull request #907 from souvikpramanikgit/add-spinner
Browse files Browse the repository at this point in the history
Add Fidget Spinner
  • Loading branch information
UTSAVS26 authored Oct 29, 2024
2 parents ea032b1 + 321863c commit b2e67c7
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
38 changes: 38 additions & 0 deletions Game_Development/Fidget Spinner/Readme.md
Original file line number Diff line number Diff line change
@@ -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!
36 changes: 36 additions & 0 deletions Game_Development/Fidget Spinner/main.py
Original file line number Diff line number Diff line change
@@ -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()
2 changes: 2 additions & 0 deletions Project-Structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b2e67c7

Please sign in to comment.