forked from fineanmol/Hacktoberfest2024
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This Is Python Code For Fidget Spinner Colored As BLUE,YELLOW,RED.
- Loading branch information
1 parent
e2c11b4
commit b5c7dbd
Showing
1 changed file
with
54 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,54 @@ | ||
|
||
from turtle import * | ||
|
||
state= {'turn':0 } | ||
|
||
def spin(): | ||
clear() | ||
|
||
angle = state['turn']/10 | ||
|
||
right(angle) | ||
forward(100) | ||
dot(130, 'blue') | ||
|
||
back(100) | ||
|
||
"second dot" | ||
right(120) | ||
forward(100) | ||
dot(130, 'yellow') | ||
back(100) | ||
|
||
"third dot" | ||
right(120) | ||
forward(100) | ||
dot(130, 'red') | ||
back(100) | ||
right(120) | ||
|
||
update() | ||
|
||
def animate(): | ||
if state['turn']>0: | ||
state['turn']-=1 | ||
|
||
spin() | ||
ontimer(animate, 20) | ||
|
||
def flick(): | ||
state['turn']+=40 #acceleration of spinner | ||
|
||
setup(600, 400, 370, 0) | ||
bgcolor("black") | ||
|
||
tracer(False) | ||
|
||
width(60) | ||
color("orange") | ||
|
||
onkey(flick,'space') | ||
|
||
listen() | ||
animate() | ||
done() |