-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #907 from souvikpramanikgit/add-spinner
Add Fidget Spinner
- Loading branch information
Showing
3 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters