MCPcopy Create free account
hub / github.com/codemistic/Web-Development / spinner

Function spinner

Fidget Spinner/FidgetSpinner.py:105–165  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

103
104# The Main Function
105def spinner():
106 spin = True
107
108 angle = 0
109
110 speed = 0.0
111 friction = 0.03
112 rightPressed = False
113 leftPressed = False
114
115 direction = 1
116 color = [[red, dark_red], [blue, dark_blue], [yellow, dark_yellow], [green, dark_green], [orange, dark_orange]]
117 index = 0
118
119 while spin:
120 for event in pygame.event.get():
121 if event.type == pygame.QUIT:
122 close()
123 if event.type == pygame.KEYDOWN:
124 if event.key == pygame.K_q:
125 close()
126 if event.key == pygame.K_RIGHT:
127 rightPressed = True
128 direction = 1
129 if event.key == pygame.K_LEFT:
130 leftPressed = True
131 direction = -1
132 if event.key == pygame.K_SPACE:
133 index += 1
134 if index >= len(color):
135 index = 0
136 if event.type == pygame.KEYUP:
137 leftPressed = False
138 rightPressed = False
139
140 # Changing the Angle of rotation
141 if direction == 1:
142 if rightPressed:
143 speed += 0.3
144 else:
145 speed -= friction
146 if speed < 0:
147 speed = 0.0
148 else:
149 if leftPressed:
150 speed -= 0.3
151 else:
152 speed += friction
153 if speed > 0:
154 speed = 0.0
155
156 display.fill(background)
157
158 angle += speed
159
160 # Displaying Information and the Fidget Spinner
161 show_spinner(angle, color[index][0], color[index][1])
162 show_info(friction, speed)

Callers 1

FidgetSpinner.pyFile · 0.85

Calls 4

closeFunction · 0.85
show_spinnerFunction · 0.85
show_infoFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected