Fidget Spinner in python ..😀

 If you are a programmer who want to relax yourself without spending money on fidget spinner ,this project is for you ...


from turtle import *   # in-built module

state={'turn':0}

def spinner(): # function to make it spin
clear()
angle=state['turn']/10
right(angle) # will make the spinner spin right by the given angle above
forward(100)
dot(120,'blue')
back(100)
right(120)
forward(100)
dot(120, 'blue')
back(100)
right(120)
forward(100)
dot(120, 'blue')
back(100)
right(120)
update() # update the given function

def animate(): # function for animation
if state['turn']>0:
state['turn']-=1
spinner() # calling the spinner function
ontimer(animate,20)

def flick(): # function to flick the fidget spinner
state['turn']+=50

tracer(False)
width(20)
bgcolor('#212121')
title('fidget spinner') # if you are in pycharm ,it might show an error ,just ignore it ..
onkey(flick,'space') # it will start rotating once the space bar is pressed ..
listen()
animate() # calling the animate function
done()


And the output ...

I encourage you to change the parameters ,colors and other stuff to make it cool ...


Comments

Popular posts from this blog

Geolocation in HTML ..

Snake game in Python ..🐱‍🐉🐲

Clock development [PART 1 : in HTML]